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)
        {
            Console.WriteLine("Unesite sumu: ");
            long V = long.Parse(Console.ReadLine());
            int k = 0; 
            long pom = V;
            while(pom >= 10)
            {
                pom /= 10;
                k++;
            }
            if(k < 18)
            {
                int[] d = { 1, 2, 5 };
                int index;
                int broj_novcanica = 0;
                while (V != 0)
                {
                    index = 2;
                    while ( V - (long)(d[index] * Math.Pow(10, k))  < 0)
                    {
                        index--;
                        if (index < 0)
                        {
                            index = 2;
                            k--;
                        }
                    }
                    long novcanica = (long)(d[index] * Math.Pow(10, k));
                    while (V >= novcanica)
                    {
                        V -= novcanica;
                        broj_novcanica++;
                    }
                }
                Console.WriteLine("Broj novcanica je: "+ broj_novcanica);
            }
            else
            {
                Console.WriteLine("Greska!");
            }
            Console.ReadKey();
        }
    }
}