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

namespace kval11
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int br = 0;
            int k = 0;
            while (k < s.Length)
            {
                int a = int.Parse(Convert.ToString(s[k]));
                while (a >= 5)
                {
                    a -= 5;
                    br++;
                }
                while (a >= 2)
                {
                    a -= 2;
                    br++;
                }
                if (a == 1)
                {
                    a--;
                    br++;
                }
                k++;
            }
            Console.WriteLine(br);
        }
    }
}