#include <iostream>
#include<math.h>
#include<cmath>
using namespace std;

int main()
{
	long long v, b, z, c;
	cin >> v;
	b = v;
	c = 0;
	while (b != 0) {
		b /= 10;
		c++;
	}
	z = 0;
	c -= 1;
	for (c; c >= 0; c--) {
		z += v / (pow(10,c) * 5);
		v = fmod(v,pow(10, c) * 5);
		z += v / (pow(10, c) * 2);
		v = fmod(v, pow(10, c) * 2);
		z += v / pow(10.0, c);
		v = fmod(v, pow(10, c));
	}
	cout << z;
}