#include <bits/stdc++.h>
using namespace std;
/// d*10^k
/// d = {1, 2, 5}

long long int novcanice[100];

int main()
{
    int x = 0, mod1;
    long long int k = 1;

    for(int i = 0; i < 19; i++)
    {
        novcanice[x] = 1 * k;
        x++;
        novcanice[x] = 2 * k;
        x++;
        novcanice[x] = 5 * k;
        x++;

        k = k * 10;
    }

    vector<long long int> vctr(novcanice, novcanice + x);
    vector<long long int>::iterator lower;

    long long int v, novcanica;
    scanf("%lld", &v);

    int brNovcanica = 0, index;
    while(v > 0)
    {
        lower = lower_bound (vctr.begin(), vctr.end(), v);
        index = (lower - vctr.begin());

        if(v == novcanice[index])
        {
            brNovcanica = brNovcanica + 1;
            break;
        }
        else
        {
            novcanica = novcanice[index - 1];
            mod1 = v / novcanica;
            brNovcanica = brNovcanica + mod1;
            v = v - mod1 * novcanica;

        }

    }

    printf("%d", brNovcanica);

    return 0;
}