#include <iostream>
#include<math.h>
using namespace std;
int novcanica(int v) {
	int x = 0, d[3] = { 1,2,5 }, z = 0, y;
	for (int i = 0;z==0; i++) {
		for (int j = 0; j < 3; j++) {
			y = d[j] * pow(10, i);
			if (y <= v)x = y;
			else { z = 1; break; }
		}
	}return x;
}
int main(){
	int v, x, z = 0;
	cin >> v;
	while (v > 0) {
		x = novcanica(v);
		v -= x;
		//cout << x;
		z++;
	}
	cout << z;
	return 0;
}