import java.util.Scanner;
public class zad1 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int[] d = new int[3];
        d[2] = 5;
        d[1] = 2;
        d[0] = 1;
        int rez = 0;

        System.out.println((long) (Math.pow(10, 0)));
        System.out.println((long) Math.log10(523));
        Long v = s.nextLong();

        while (v > 0) {

            for (long i = (long) (Math.log10(v)); i >= 0; i--) {
                for (int j = 2; j >= 0; j--) {
                    if ((long)(Math.pow(10,i) * d[j]) <= v)
                    {
                        while (v>= (Math.pow(10,i) * d[j]))
                        {
                            v=v-(long)Math.pow(10,i) * d[j];
                            rez++;
                        }
                    }
                }
            }
        }
        System.out.print(rez);
    }
}