using System;

namespace Isplata
{
    class Program
    {
        static long Stepen(long n)
        {
            long st = 1;

            while (n >= 10)
            {
                st *= 10;
                n /= 10;
            }

            return st;
        }
        
        static void Main(string[] args)
        {
            int[] d = {1, 2, 5};
            long v = long.Parse(Console.ReadLine());
            var st = Stepen(v);
            var c = 0;

            while (st > 0)
            {
                for (int i = 2; i >= 0; i--)
                {
                    long s = d[i] * st;
                    while (v - s > 0 && s <= v)
                    {
                        v -= s;
                        c++;
                    }
                }

                st /= 10;
            }

            Console.WriteLine(c);
        }
    }
}