using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            long brdec = 1;
            long V = long.Parse(Console.ReadLine());
            long v2 = V;
            byte brnovcanica = 0;
            
            while (v2 > 0)
            {
                if ((v2 / 10) % 10 >= 0)
                {


                    brdec *= 10;

                }
                v2 /= 10;
            }
           
            v2 = V;
            while (v2 > 0)
            {
                if (v2 / (5 * (long)(brdec / 10)) > 0)
                {
                    brnovcanica++;
                    v2 = v2 - (long)5 * brdec / 10;
                }
                else
                {
                    if (v2 / (2 * (long)(brdec / 10)) > 0)
                    {
                        brnovcanica++;
                        v2 = v2 - (long)2 * brdec / 10;
                    }
                    else
                    {
                        if (v2 / (1 * (long)(brdec / 10)) > 0)
                        {
                            brnovcanica++;
                            v2 = v2 - (long)1 * brdec / 10;
                        }
                        else
                        {
                            brdec /= 10;
                        }
                    }
                }

                
            }
            Console.WriteLine(brnovcanica);
            }
            
        }
}