using System;

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