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

	long long imp;
	std::cin >>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--;
	}
	
	
	std::cout<< br;

	
	
	return 0;
}