package isplata;

import java.util.Scanner;


public class Isplata {


    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        long uplata = sc.nextLong();
        
        long[] d = new long[3];
        d[0]=1;
        d[1]=2;
        d[2]=5;
        long najveci = 0;
        int br=0;
        while(!(uplata==0)){
            najveci =0;
            for (int k = 18; k >= 0; k--) {
                for (int i = 2; i >= 0; i--) {
                    if (d[i]* Math.pow(10, k)>najveci &&  d[i]* Math.pow(10, k) <=uplata) {
                        najveci =  (long) (d[i]* Math.pow(10, k));
                    }
                 
                }
            }
            uplata -= najveci;
            br++;
        }
        System.out.println(br);
       
        
        
    }
    
}