#include <bits/stdc++.h>
using namespace std;
int main () {
	unsigned long long n ;
	cin >> n ;
	int c = 0;
	unsigned long long p = 1000000000000000000 ;
	while ( n > 0 ) {
		if ( 5 * p <= n ) {
			n -= 5* p;
			c++;
		}
		else if ( 2 * p <= n ) {
			n -= 2* p;
			c++;
		}
		else if ( 1 * p <= n ) {
			n -= 1* p;
			c++;
		}
		else p/=10;
	}
	cout << c;

}