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

namespace novcanice
{
	class Program
	{
		public static void Novcanice(int suma)
		{
			var suma1 = suma;
			var brjc = 0;
			var k = 1;
			int[] d = { 5, 2, 1 };
			while (suma1 > 10)
			{
				suma1 = suma1 / 10;
				k = k * 10;
			}
			do
			{
				for (int i = 0; i < 3; i++)
				{
					var o = d[i] * k;
					while (o <= suma)
					{
						suma = suma - o;
						brjc++;
					}
				}
				k = k / 10;
			}
			while (suma > 0 && k >= 1);
			Console.WriteLine(brjc);
		}
		 static void Main(string[] args)
		{
			int suma = int.Parse(Console.ReadLine());
			Novcanice(suma);

		}
	}
}