package net.pinger.takmicenje;

import java.util.Scanner;

public class Takmicenje {

    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long fix = scanner.nextInt();

        getMinimum(fix);
    }

    public static void getMinimum(long fixed) {
        final int[] d = new int[] {1, 2, 5};

        int koraci = 0;
        long novi = 0;

        while (fixed > 0) {
           for (int i = 0; i < d.length; i++) {
               long check = (long) (d[i] * Math.pow(10, (int) Math.log10(fixed + 1)));
               if (check > fixed) {
                   continue;
               }

               novi = check;
           }

           fixed -= novi;
           koraci++;
        }

        System.out.println(koraci);
    }


}