#include <stdio.h>
#include <math.h>

int main()
{
	int d[]={1,2,5};
	int i,j,v;
	int br=0,x,s,k,pom;
	
	scanf("%d",&v);
	
	while(v>0)
	{
		x=1; s=0; k=0;
		
		while(v>=x)
		{
			pom=x;
			x=d[k++]*pow(10,s);
			
			if(k==3)
			{
				k=0; s++;
			}
		}		
		v-=pom;
		br++;
	}
	printf("%d",br);
}