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

namespace ConsoleApp24
{
    class Program
    {
        static void Main(string[] args)
        {
            int v = int.Parse(Console.ReadLine());
            int b = 0;
            while (v > 0)
            {
                int d = v % 10;
                if (d == 1 || d == 2 || d == 5)
                    b++;
                else
                    b += d / 5 + (d - (d / 5) * 5) / 2 + ((d - (d / 5) * 5) / 2) % 2;
                v /= 10;
            }
            Console.WriteLine(b);
        }
    }
}