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

int main()
{
	long long n,v;
	n = 0;
	cin >> v;
	while (v > 0)
	{
		string s = to_string(v);
		long long k = s.length() - 1;
		long long power = pow(10, k);
		n++;
		if (5 * power <= v)
		{
			v = v - 5 * power;
		}
		else if (2 * power <= v)
		{
			v = v - 2 * power;
		}
		else if (power <= v)
		{
			v = v - power;
		}
	}
	cout << n;
}