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

namespace petlja
{
	class Program
	{
		static void Main(string[] args)
		{
			ulong suma = Convert.ToUInt64(Console.ReadLine());
			int brNovcanica = 0, n;
			while (suma > 0)
			{
				n = (int)(suma % 10);
				while (n > 0)
				{
					if (n >= 5)
					{
						n -= 5;
						brNovcanica++;
					}
					else if (n >= 2)
					{
						n -= 2;
						brNovcanica++;
					}
					else if (n == 1)
					{
						n--;
						brNovcanica++;
					}
				}
				suma /= 10;
			}
			Console.WriteLine(brNovcanica);
		}
	}
}