import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Isplata {


    public static void main(String[] args) throws IOException {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        long uplata = Long.parseLong(br.readLine());
        //long start = System.currentTimeMillis();
        long[] d = new long[3];
        d[0]=1;
        d[1]=2;
        d[2]=5;
        long najveci = 0;
        int brojac=0;
        //long k = String.valueOf(uplata).length()-1;
//        int k = (int) (Math.log10(uplata));
        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;
            brojac++;
        }
        System.out.println(brojac);
        //System.out.println(System.currentTimeMillis() - start);
        
        
    }
    
}