#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	long long a=10,v,k,i=1,s=0,s1=0,g,e,f,h;
	int b=5,c=2,d=1;
	cin>>v;
	while (v>i)
	{
		i*=a;
		s++;
	}
	h=pow(a,s);

		for (k=0;k<s+1;k++)
		{
		
		while (v>=b*h)
		{
			v=v-b*h;
			s1++;
		
			
		}
		while (v>=c*h)
		{
			v=v-c*h;
			s1++;
		
		}
		while (v>=d*h)
		{
			v=v-d*h;
			s1++;
		
		}
		h=h/10;
		
	}
	cout<<s1;

}