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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Int64 Value;

            Value = Convert.ToInt64(Console.ReadLine());

            String ValStr = Value.ToString();
            int count = 0;
            int tempNum;
            foreach (char num in ValStr)
            {
                tempNum = int.Parse(num.ToString());
                while (tempNum > 0)
                {
                    if (tempNum >= 5)
                    {
                        tempNum -= 5;
                        ++count;
                    }
                    else if (tempNum >= 2)
                    {
                        tempNum -= 2;
                        ++count;
                    }
                    else if (tempNum >= 1)
                    {
                        tempNum -= 1;
                        ++count;
                    }
                }
            }

            Console.WriteLine(count);
            
        }
    }
}