#include <iostream>
int le(unsigned long long a) {
	int i = 0;
	while (a >= 10)
	{
		++i;
		a /= 10;
	}
	return i;
}
int eh(unsigned long long a) {
	if (a == 0) return 0;
	int l, t, s, s1;
	l = le(a);
	t = int(a / unsigned long long(pow(10, l)));
	a -= t * unsigned 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() {
	unsigned long long a;
	std::cin >> a;
	std::cout << eh(a);
	return 0;
}