#include <iostream>
#include <cmath>


using namespace std;

int main()
{
    double V,Vostatak,d1,d2,d5;
    int brojac=0;

    cin>>V;
    Vostatak=V;
    for(double i=18;i>-1;i--)
    {
        d5=(double)5*pow(10,i));
        d2=(double)(2*pow(10,i));
        d1=(double)(1*pow(10,i));
        if(Vostatak>=d5 )
        {
            V=Vostatak/d5;
          Vostatak=Vostatak%d5;

          brojac=brojac+V;
        }
        if(Vostatak>=d2 )
        {
                V=Vostatak/d2;
                Vostatak=Vostatak%d2;

                brojac=brojac+V;
        }
        if(Vostatak>=d1 )
        {


                V=Vostatak/d1;
                Vostatak=Vostatak%d1;

                brojac=brojac+V;

        }
    }

    cout<<brojac;
}