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