#include <cmath>
#include <cmath>
using namespace std ;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int f1 (int x) {
	int b = x / 5;
	x = x % 5;
	if (x == 0) return (b);
	b = x / 2 ;
	x = x % 2 ;
	if (x == 0) return (b);
	b = x / 1;
	x = x % 1;
	return (b);
}




int f (int n) {
	int x;
	int b1 = 0;
	int k = 0;
	while (x > 0){
		x = (n / pow(10,k)) % 10;
		b1 = b1 + f1(x);
		k = k + 1;
	}
}




int main(int argc, char** argv) {
	int v,b;
	cin >> v;
    b = f (v);
    cout << b << endl;
	
	return 0; 
}