#include <bits/stdc++.h>
using namespace std;
vector<int>v;
int izracunaj (int n) {
	for (int i = 11; i >= 0 ; i-- ) {
		if ( v[i] <= n ) {
			n-=v[i];
			return 1 + izracunaj(n);
		}
	}
	return 0 ;
}
int main () {
	long long n ;
	cin >> n ;
	v.push_back(1);
	v.push_back(2);
	v.push_back(5);

	v.push_back(10);
	v.push_back(20);
	v.push_back(50);

	v.push_back(100);
	v.push_back(200);
	v.push_back(500);

	v.push_back(100000);
	v.push_back(200000);
	v.push_back(500000);

	
	cout << izracunaj(n);

}