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

namespace ConsoleApp1
{
	class Program
	{ 	
		static long countTotal(long n){
			long s = 0;
			while(n > 0){
				long digit = n % 10;
				s += getCoins(digit);
				n /= 10;
			}
			return s;
		}


		static long getCoins(long v){

			long[] coins = {1,2,5};
						
			int req = 0;

			for(int i = 2; i >= 0; i--){
				while(v >= coins[i]){
					v -= coins[i];
					req++;
				}

			}
			return req;
		}
		
		static void Main(string[] args)
		{
			long v = long.Parse(Console.ReadLine());

			Console.WriteLine(countTotal(v));
		}
	}
}