#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	long long t[54];
	int j = 0;
	for (long long i = 1; j < 18; j++, i *= 10) {
		t[3 * j] = i;
		t[3 * j + 1] = 2 * i;
		t[3 * j + 2] = 5 * i;
	}
	long long v;
	cin >> v;
	int s = 0;
	for (int i = 53; i >= 0; i--) {
		s += v / t[i];
		v %= t[i];
	}
	cout << s;
	return 0;
}