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

namespace zadatak1
{
    class Program
    {
        static void Main(string[] args)
        {
            int v = Convert.ToInt32(Console.ReadLine()); int s = v; int f = 1;
            int[] a = new int[3]; int br = 0; int g = 1; int st = 0;
            a[0] = 5; a[1] = 2; a[2] = 1;
            while (s > 9)
            {
                f = f * 10;
                s = (s-s%10)/10;
                st++;
            }
            for (int i = 0; i <= st; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    g = a[j]*f;
                    if (g<=v)
                    {
                        br = br + v / g;
                        v = v % g;
                    }
                }
                f = f / 10;
            }
            
            Console.WriteLine(br);
        }
    }
}