#include <iostream>
#include <cmath>

using namespace std;

int main() {
    long long v, v2 ,c;
    int k ,d ,i;
    
    k = 0;
    i = 0;
    cin >> v;
    while (v > 0) {
        v2 = v;
        while (v > 10) {
            v = v / 10;
            k = k + 1;
        }
        if (v >= 5) {
            d = 5;
        } else {
            if (v >= 2) {
                d = 2;
            } else {
                d = 1;
            }
        }
        c = d * pow(10, k);
        v = v2;
        v = v - c;
        i = i + 1;
        k = 0;
    }
    cout << i << endl;
    return 0;
}