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

namespace Ipslata
{
    class Program
    {
        static void Main(string[] args)
        {
            double suma, broj = 0, prethodni = 0;
            Console.WriteLine("Unesite sumu : ");
            suma = Double.Parse(Console.ReadLine());
            for (double i = 0; i < double.MaxValue-1; i++)
            {
                for (double j = 1; j <=5; j++)
                {
                    if (j == 1 || j == 2 || j == 5)
                    {
                        if ((j * (double)Math.Pow(10, i)) > suma)
                        {
                            suma -= prethodni;
                            broj++;
                            if (suma <= 0)
                            {
                                i = double.MaxValue;
                                j = 6;
                            }
                            else
                            {
                                i = 0;
                                j = 1;
                            }    
                        }
                        prethodni = j * (double)Math.Pow(10, i);
                    }
                }
            }
            Console.WriteLine("Minimalan potreban broj novcanica : {0}", broj);
            Console.ReadKey();
        }
    }
}