#include<iostream>
using namespace std;
long long int zbir(long long int v)
{
    long long int s=0,i,j,d,k;
    while(v>0)
    {
        k=1;
        while(k*10<v)
            k*=10;
        if (5*k<=v)
            d=5*k;
        else if (2*k<=v)
            d=2*k;
        else
            d=k;
        s+=v/d;
        v%=d;
    }
    return s;
}
int main()
{
    long long int v;
    cin>>v;
    cout<<zbir(v);
}