using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string V;
            do
            {
                V = Console.ReadLine();
            }
            while (Convert.ToInt64(V) <= 0);

            int br = 0;
            int c;
            for (int i = 0; i < V.Length; i++)
            {
                c = Convert.ToInt32(V.Substring(i, 1));
                if (c >= 5)
                {
                    br++;
                    c = c - 5;
                }
                while (c >= 2)
                {
                    br++;
                    c -= 2;
                }
                if (c == 1)
                {
                    br++;
                }
            }
                Console.WriteLine(br);
                
            
        }
    }
}