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

namespace ConsoleApp3
{
    class Program
    {
        static int brcifara(long V) {
            int i;
            for (i = 0; V>9 ;i++)
            {
                V = V / 10;
            }
            return i;
        }
        static void Main(string[] args)
        {
            long V;
            V=Convert.ToInt64(Console.ReadLine());
            int bc;
            int pc,i;
            for (i = 0; V!=0; i++)
            {
                bc = brcifara(V);
                pc = (int)(V / Math.Pow(10, bc));
                if (pc>=1)
                {
                    V -= (long)(1 * Math.Pow(10, bc));
                   
                    
                }
                else if(pc>=2)
                {
                    V -= (long)(2 * Math.Pow(10, bc));

                }
                else
                {
                    V -= (long)(5 * Math.Pow(10, bc));
                }
            }
            Console.WriteLine("{0}", i);
            
        }
    }
}