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

namespace isplata
{
    class Program
    {
        static Int64 stepen(int i)
        {
            Int64 n = 1;
            if (i == 0)
                return n;
            else
            {
                for (int j = 1; j <= i; j++)
                {
                    n *= 10;
                }
                return n;
            }
        }
        static void Main(string[] args)
        {
            Int64 v = Int64.Parse(Console.ReadLine());
            Int64 brnovcanica = 0;
            int i, j, k = -1;
            Int64 unisti = v;
            Int64 v2;
            Int64 c;
            while(unisti!=0)
            {
                unisti /= 10;
                k++;
            }
            for (i = k; i >= 0; i-- )
            {
                if (i != 0)
                {
                    if (v % (5 * stepen(i)) <= stepen(i+1))
                    {
                        c = v % 10;
                        v -= c;
                        v2 = v / (5 * stepen(i));
                        brnovcanica += v2;
                        v -= v2 * stepen(i) * 5;
                        v+=c;
                    }
                    if (v % (2 * stepen(i)) <= stepen(i+1))
                    {
                        c = v % 10;
                        v -= c;
                        v2 = v / (2 * stepen(i));
                        brnovcanica += v2;
                        v -= v2 * stepen(i) * 2;
                        v+=c;
                    }
                    if (v % stepen(i) <= stepen(i+1))
                    {
                        c = v % 10;
                        v -= c;
                        v2 = v / stepen(i);
                        brnovcanica += v2;
                        v -= v2 * stepen(i);
                        v += c;
                    }
                }
                else
                {
                    if (v >= 5)
                    {
                        v2 = v / (5 * stepen(i));
                        brnovcanica += v2;
                        v -= v2 * stepen(i) * 5;
                    }
                    if (v >= 2)
                    {
                        v2 = v / (2 * stepen(i));
                        brnovcanica += v2;
                        v -= v2 * stepen(i) * 2;
                    }
                    if (v >=1)
                    {
                        v2 = v / stepen(i);
                        brnovcanica += v2;
                        v -= v2 * stepen(i);
                    }
                }
            }
            Console.WriteLine(brnovcanica);
        }
    }
}