package mytestprojekt;

import java.util.Scanner;

public class A1 { 

	public static void main(String[] args) {
	
		Scanner sc=new Scanner(System.in);	
		Long v=sc.nextLong();
		sc.close();
					
	long m=0;	
	long h=0;
	long number=0;

	long b=v;
	double g= Math.log10(b);
	long k=(long)Math.ceil(g)-1 ;
	
    while (b>0) {   
    	
    	g= Math.log10(b);
    	if (Math.ceil(g)-1 > 0) {k=(long)Math.ceil(g)-1;}
    	 else {k=0;}
    	
    	if (k>0) {number = (long)(b/(Math.pow(10, k)));}
    	 else {number = b;}
    	 
    if (number==9 || number==8 || number==7 || number==6 || number==5) {	
        m=(long)Math.pow(10,k)*5;
       } 	
    
    if (number==4 || number==3 || number==2) {	
        m=(long)Math.pow(10,k)*2;
       }	
     
    if (number==1) {	
        m=(long)Math.pow(10,k)*1;
       }	
    
        double o= Math.floor(b/m); 	
        long u= (int)(o);
        b= b - (u*m); 	
        h= h+1*u;    
    }
    
    System.out.println(h);
       
	}
		
}