using System;
class Program {
    static void Main() {
        long V, k, br, c, i, j;
        V = long.Parse(Console.ReadLine());
        k = V.ToString().Length;
        c = (long)(V / (Math.Pow(10, (k-1))));
        br = 0;
        j = k;
        for (i = 1; i <= k; i++) {
            V = (long)(V - (c * Math.Pow(10,(j-1))));
            j--;
            while (c > 0) {
                if (c >= 5) {
                    c -= 5;
                    br++;
                }
                else if(c >= 2) {
                    c -= 2;
                    br++;
                }
                else{
                    c -= 1;
                    br++;
                }
            }
            c = (long)(V / Math.Pow(10, (j - 1)));
        }
        Console.WriteLine(br);
    }
}