#include <iostream>
#include <cmath>


using namespace std;

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

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