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

using namespace std;

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

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

    while(v != 0)
    {
        k = log10(v);
        kN = (int)k;
        kNN = (int)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;
}