#include <iostream>

using namespace std;
int broj(long long k,long long t)
{
    return k/t;
}
long long stepen(long long k)
{
    long long r=1;
    k/=10;
    while(k>0)
    {
        r*=10;
        k/=10;
    }
    return r;
}
int main()
{
    long long x; int b=0,c;
    cin>>x;
    while(x>0)
    {
        c=broj(x,stepen(x));
        if(c>=5) x-=5*stepen(x);
        else if(c>=2) x-=2*stepen(x);
        else x-=stepen(x);
        b++;
    }
    cout<<b<<endl;
    return 0;
}