using System;

namespace PetljaZadatak1
{
    class Program
    {
        static void Main(string[] args)
        {
            double v = Convert.ToDouble(Console.ReadLine());
            double[] x = new double[Int16.MaxValue/100];
            int i = 0;
            int br = 0;
            Console.WriteLine(v);
            int d;
            long lmao = 1;
            while(true)
            {
                d = 1;
                if (d * lmao <= v)
                {
                    x[i] = d * lmao;
                    
                    i++;
                }
                else break;
                d = 2;
                if (d * lmao <= v)
                {
                    x[i] = d * lmao;
                    i++;
                }
                else break;
                d = 5;
                if (d * lmao <= v)
                {
                    x[i] = d * lmao;
                    i++;
                }
                else break;
                lmao = lmao * 10;
            }
            i--;
            while(v!=0)
            {
                if(v>=x[i])
                {

                    br++;
                    double roflmao = x[i];
                    v -= x[i];
                }
                else
                {
                    i--;
                }
            }
            Console.WriteLine(br);

        }
    }
}