#include <cmath>
#include <iostream>

void comp(unsigned long long input, int* res)
{
    int k = (input > 0 ? (int)log10((double)input) + 1 : 1) - 1;

    if (k < 0)
    {
        return;
    }

    int vals[3] = { 5, 2, 1 };
    for (int val : vals)
    {
        auto test = (unsigned long long)(val * pow(10, k));
        unsigned long long mod = input % test;
        if (mod != input)
        {
            unsigned long long div = input / test;
            *res += div;
            comp(input - (div * test), res);
            return;
        }
    }
}

int main()
{
    unsigned long long input;
    std::cin >> input;

    int res = 0;
    comp(input, &res);

    std::cout << res;

    return 0;
}