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

namespace ISPLATA
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] d = { 1, 2, 5 };
            long v = Convert.ToInt64(Console.ReadLine());
            double c = Convert.ToDouble(v);
            int k = 0;
            int br = 0;
            while(c>0)
            {
                while (v > 9)
                {
                    v = v / 10;
                    k++;
                }
                if (v / 5 >= 1)
                {
                    c = c - (v / 5) * 5 * Math.Pow(10, k);
                    br += Convert.ToInt32(v / 5);
                    v -= v / 5 * 5;
                }
                if (v / 2 >= 1)
                {
                    c = c - (v / 2) * 2 * Math.Pow(10, k);
                    br += Convert.ToInt32(v / 2);
                    v -= v / 2 * 2;
                }

                if (v > 0)
                {
                    c = c - v * Math.Pow(10, k);
                    br += Convert.ToInt32(v);
                }
                k = 0;
                v = Convert.ToInt64(c);
            }
            Console.WriteLine(br);
        }
    }
}