#include <iostream>
#include <math.h>

#define OSTATAK2 0.3010299957
#define OSTATAK5 0.6989700043

using namespace std;

int main()
{
    long long v, resenje = 0;
    cin >> v;

    while(v)
    {
        float a = log10(v);
        float b = floor(a);
        float c = a-b;
        long long d;
        if(c<OSTATAK2)
        {
            d = pow(10, b);
        }
        else if(c<OSTATAK5)
        {
            d = pow(10, b)*2;
        }
        else
        {
            d = pow(10, b)*5;
        }
        resenje += v/d;
        v = v % d;
    }

    cout << resenje;
}