#include <iostream>
using namespace std;
int main() {
int n,tmp = 0 ,cnt=0;
cin >> n;
if (n >= 50000) {
tmp = n / 50000;
cnt += tmp;
n -= tmp * 50000;
tmp = 0;
}
if (n >= 10000) {
tmp = n / 10000;
cnt += tmp;
n -= tmp * 10000;
tmp = 0;
}
if (n >= 5000) {
tmp = n / 5000;
cnt += tmp;
n -= tmp * 5000;
tmp = 0;
}
if (n >= 1000) {
tmp = n / 1000;
cnt += tmp;
n -= tmp * 1000;
tmp = 0;
}
if (n >= 500) {
tmp = n / 500;
cnt += tmp;
n -= tmp * 500;
tmp = 0;
}
if (n >= 100) {
tmp = n / 100;
cnt += tmp;
n -= tmp * 100;
tmp = 0;
}
if (n >= 50) {
tmp = n / 50;
cnt += tmp;
n -= tmp * 50;
tmp = 0;
}
if (n >= 10) {
tmp = n / 10;
cnt += tmp;
n -= tmp * 10;
tmp = 0;
}
cout << cnt;
}