//read medaka box

#include <bits/stdc++.h>

typedef unsigned long long __uint64;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);

    __int64 V;
    __int64 c = 0;
    cin >> V;

    vector<__int64> s;
    vector<__int64> k = {1, 2, 5};
    __int64 d = 1;

    __int64 i = 0;

    while(k[i] * d <= V)
    {
        s.push_back(k[i] * d);
        i++;
        if(i == 3)
        {
            i = 0;
            d *= 10;
        }
    }

    i = s.size() - 1;

    while(V > 0)
    {
        while(V < s[i])
            i--;
        V -= s[i];
        c++;
    }

    cout << c << '\n';

    cout.flush();
    return 0;
}