using System;
class Program
{
    static void Main(string[] args)
    {
        int b = 0;
        ulong a = ulong.Parse(Console.ReadLine());
        int dig = Convert.ToInt32(Math.Floor(Math.Log10(a) + 1));
        while (dig > 0)
        {
            b++;
            ulong x = Convert.ToUInt64(Math.Pow(10, dig - 1));
            if (a < Convert.ToUInt64(Math.Pow(10, dig-1)) * 2)
            {
                a -= x;
            } else if (a < Convert.ToUInt64(Math.Pow(10, dig - 1)) * 5)
            {
                a -= 2 * x;
            }
            else
            {
                a -= 5 * x;
            }
            if (a != 0)
                dig = Convert.ToInt32(Math.Floor(Math.Log10(a) + 1));
            else dig = 0;
        }
        
        Console.WriteLine(b);

    }
}