#include <iostream>

using namespace std;
unsigned long long int stepen (unsigned long long int a)
{
    int b = 0;
    unsigned long long int m=1;
    while(a>0){
        a/=10;
        b++;
    }
    b--;
    if(b!=0)
    {
        while(b>0){
            m*=10;
            b--;
        }
    }
    else m=1;
    return m;
}
int main()
{
    unsigned long long int a;
    int c=0;
    cin>>a;
    while (a>0)
    {
        unsigned long long int s = stepen(a);
        if(a/(5*s)>0){
            c+=a/(5*s);
            a%=5*s;
        }
        if(a/(2*s)>0){
            c+=a/(2*s);
            a%=2*s;
        }
        if(a/s>0){
            c+=a/s;
            a%=s;
        }
    }
    cout<<c;
    return 0;
}