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

namespace novcanice
{
    class Program
    {
        static void Main(string[] args)
        {
            int v = Convert.ToInt32(Console.ReadLine());
            int
 v1 = v;
            int k = 1;
            while (v1 > 10)
            {
                v1 /= 10;
                k *= 10;
            }
            int[] d = { 5, 2, 1 };
            int brn = 0;
            while (v > 0&&k>=1)
            {
                for (int i = 0; i < 3; i++)
                {
                    int p = d[i] * k;
                    while (p <= v)
                    {
                        v = v - p;
                        brn++;
                    }
                } 
                k /= 10;
            }
            Console.WriteLine(brn);

            
        }
    }
}