using System;

namespace ConsoleApp6
{
    class Program
    {
        static double a;
        static double novcanica = 1;
        static double stepen = 0;
        static double tempStepen;
        static int Main(string[] args)
        {
            a = double.Parse(Console.ReadLine());
            if(a < 1)
            {
                Console.WriteLine("Greska");
                return;
            }
            int brojac = 0;
            while(a > 0)
            {
                PronadjiNajvecuNovcanicu();
                //Console.WriteLine(novcanica + " * 10^" + stepen);
                a -= novcanica * Math.Pow(10, stepen);
                brojac++;
            }
            return brojac;
        }
        static void PronadjiNajvecuNovcanicu()
        {
            novcanica = 1;
            stepen = 0;
            double i = 0;
            while (i >= 0)
            {
                tempStepen = Math.Pow(10, i);
                if (5 * tempStepen <= a)
                {
                    novcanica = 5;
                    stepen = i;
                }
                else if (2 * tempStepen <= a)
                {
                    novcanica = 2;
                    stepen = i;
                }
                else if (1 * tempStepen <= a)
                {
                    novcanica = 1;
                    stepen = i;
                }
                else 
                {
                    break;
                }
                i++;
            }
        }
    }
}