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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
           long v = long.Parse(Console.ReadLine());
            int br = 0;
            while (v > 0)
            {
                int p=Convert.ToInt32(v%10);
                if ( p>= 5)
                {
                    p -= 5;
                    br++;
                }
                    if (p >= 2)
                    {
                        br += p / 2;
                        p %= 2;
                    }
                    if (p == 1)
                        br++;
                    v = v / 10;
            }
            Console.WriteLine(br);
            Console.ReadLine();
        }
    }
}