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

namespace Zadatak_1
{
    class Program
    {
        static void Main(string[] args)
        {
            double V;
            double y;
            int[] niz = new int[3] { 5, 2, 1 };
            int k = 0;

            V = Convert.ToDouble(Console.ReadLine());

            double broj = Math.Pow(10, 18);

            while (V != 0)
            {
                broj = broj / 10;
                for (int i = 0; i < 3; i++)
                {
                    y = niz[i] * broj;
                    if (V >= y)
                    {
                        k++;
                        i--;
                        V = V - y;

                    }
                }
            }

            Console.WriteLine("{0}", k);
        }
    }
}