#include<stdio.h>
#include<math.h>
int main()
{
int br=0;
int pv=17;
long  p;
int g;

	long  imp;
	scanf("%ld",&imp);


	
	while(pv>-1)
	{
		p=5*pow(10,pv);
		g=imp/p;
		br=br+g;
		imp=imp-g*p;
		
		p=p*2/5;
		g=imp/p;
		br=br+g;
		imp=imp-g*p;
		
		p=p/2;
		g=imp/p;
		br=br+g;
		imp=imp-g*p;
		
		
		
		pv--;
	}
	
	
printf("%d",br);

	
	
	return 0;
}