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