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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int ct = 0;
            long v = Convert.ToInt64(Console.ReadLine()), v1=v, k=1, s = 0;
            while (v1 != 0)
            {
                v1 /= 10;
                k *= 10;
            }
            //k /= 10;
            while (s != v && k > 0)
            {
                while (s + (5 * k) <= v)
                {
                    s += 5 * k;
                    ct++;
                }
                while (s + (2 * k) <= v)
                {
                    s += 2 * k;
                    ct++;
                }
                while (s + k <= v)
                {
                    s += k;
                    ct++;
                }
                k /= 10;
                
            }
            Console.Write(ct);
        }
    }
}