#include <iostream>
#include <tgmath.h>

using namespace std;

int main()
{
    long long v;
    cin>>v;

    double k;
    long long kN, kNN;
    long long c = 0;

    while(v != 0)
    {
        k = log10(v);
        kN = (long long)k;
        kNN = (long long)trunc(pow(10, kN));
        while(v - 5 * kNN >= 0)
        {
            v -= 5 * kNN;
            c++;
        }
        while(v - 2 * kNN >= 0)
        {
            v -= 2 * kNN;
            c++;
        }
        while(v - kNN >= 0)
        {
            v -= kNN;
            c++;
        }
    }

    cout<<c;

    return 0;
}