#include <iostream>
#include <cmath>

typedef unsigned long long UInt64;
typedef long long Int64;
using namespace std;

int rac[] = {1,2,5};
int NadjiBrojNovcanica(UInt64 suma)
{
	int count = 0;
	while (suma != 0)
	{
		int stepen = (int)ceil(log10(suma)) - 1;
		for (int i = 2; i >= 0; i--)
		{
			Int64 sumaTemp = suma - (rac[i] * pow(10, stepen));
			if (sumaTemp >= 0)
			{
				suma = sumaTemp;
				break;
			}
		}
		count++;
	}
	return count;
}

int main()
{
	UInt64 suma;
	cin >> suma;
	cout << NadjiBrojNovcanica(suma);
}