using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong v = Convert.ToUInt64(Console.ReadLine());
            ulong pv = v;
            int bn=0;
            while (pv > 9)
            {
                pv = pv / 10;
                bn++;
            }
            pv = Convert.ToUInt64(Math.Pow(10, bn));
            bn=0;
            while (v != 0)
            {
                if (v >= (5 * pv))
                {
                    v -= 5 * pv;
                    bn++;
                }
                else if (v >= (2 * pv))
                {
                    v -= 2 * pv;
                    bn++;
                }
                else if (v >= pv)
                {
                    v -= pv;
                    bn++;
                }
                else
                {
                    pv = pv / 10;
                }
            }
            Console.WriteLine(bn);
        }
    }
}