#include <iostream>

using namespace std;

int brojCifara(long long n){
    int br=0;
    while(n!=0)
    {
        n=n/10;
        br++;
    }
    return br;
}
long long stepen(int k){
    long long rez=1;
    while(k!=0)
    {
       rez=rez*10;
       k--;
    }
    return rez;
}

int main()
{
    long long n,s;
    int k,br=0;
    cin>>n;
    while(n!=0)
    {
        k=brojCifara(n);
        s=stepen(k-1);
        br=br+n/(5*s);
        n=n%(5*s);
        br=br+n/(2*s);
        n=n%(2*s);
        br=br+n/s;
        n=n%s;
    }
    cout<<br;
}