using System;

namespace Zadatak1
{
    class Program
    {
        public static long provera(long x)
        {
            int i = 0;
            if(x!=0)
            {
                if (x >= 5)
                {
                    x -= 5;
                    i++;
                }
                while (x >= 2)
                {
                    x -= 2;
                    i++;
                }
                if (x >= 1)
                {
                    x -= 1;
                    i++;
                }
            }
            return i;
        }
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());
            long suma = 0;
            while (x > 0)
            {
                suma += provera(x%10);
                x/= 10;
            }
            Console.WriteLine(suma);
        }
    }
}