#include <iostream>
#include <cmath>

using namespace std;

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

    cin>>V;
    Vostatak=V;
    for(int i=18;i>-1;i--)
    {
        d5=(unsigned long long)5*pow(10,i));
        d2=(unsigned long long)(2*pow(10,i));
        d1=(unsigned long long)(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;
}