#include <iostream>
#include <cmath>
int eh(long long a) {
	if (a == 0) return 0;
	int l, t,s,s1;
	l = int(log10(a));
	t = a / long long(pow(10, l));
	a -= t * long long(pow(10, l));
	s = int(t / 5);
	t -= s * 5;
	s1 = int(t / 2);
	t -= s1 * 2;
	s += s1 + t;
	return s + eh(a);
}
int main() {
	long long a;
	std::cin >> a;
	std::cout << eh(a);
	return 0;
}