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

namespace isplata
{
    class Program
    {
        static void Main(string[] args)
        {
            int n =int.Parse(Console.ReadLine());
            int d, br = 0;
            while (n! > 0)
            {
                string x = Convert.ToString(n);
                int l = x.Length;
                int m = n / Math.Pow(10, l - 1);
                if (m >= 5) d = 5;
                else if (m >= 2) d = 2;
                else d = 1;
                n -= d * Math.Pow(10, l - 1);
                br++;
            }
            Console.WriteLine(br);
        }
    }
}