#include<bits/stdc++.h>
using namespace std;
int brcifara (long long a)
{
	int br=0;
	while(a>0)
	{
		br++;
		a=a/10;
	}
	return br;
}
int main()
{
	int br=0,k;
	long long suma,p;
	cin>>suma;
	while(suma>0)
	{
		 k=brcifara(suma)-1;
		 p=pow(10,k);
		 if(suma-5*p>=0) suma=suma-5*p;
		 else if(suma-2*p>=0) suma=suma-2*p;
		 else suma=suma-p;
		 br++;
	}
	cout<<br;
}