using System;

class Program
{
    static void Main() {
       double n=double.Parse(Console.ReadLine());
       double j=1,d=2,p=5,h,br=0;
       h=n;
       while(true)
       {
           if(h<10)
           {
               break;
           }
           h=h/10;
           j=j*10;
           d=d*10;
           p=p*10;
       }
       while(n!=0)
       {
           if(n/p>=1)
           {
               n=n-p;
               br++;
           }
           else if(n/d>=1)
           {
               n=n-d;
               br++;
           }
           else if(n/j>=1)
           {
               n=n-j;
               br++;
           }
           if(n/p<1 && n/d<1 && n/j<1){
               j=j/10;
               d=d/10;
               p=p/10;}
        }
        Console.WriteLine("{0}",br);
    }
}