#include <iostream>

using namespace std;

long long stepen10(int k){
    long long s = 1;
    for(int i = 1; i < k; i++){
        s *= 10;
    }
    return s;
}

int main()
{
    long long v;
    cin >> v;
    int br_novcanica = 0;
    while(v > 0){
        int broj_cifara = 0;
        long long pom = v;
        while(pom > 0){
            pom /= 10;
            broj_cifara++;
        }
        int k = broj_cifara;
        if(stepen10(k) == v){
            v = 0;
            cout << ++br_novcanica << endl;
        }
        else if(2 * stepen10(k) <= v){
            v -= 2 * stepen10(k);
            br_novcanica++;
        }
        else{
            v -= 5 * stepen10(k);
            br_novcanica++;
        }
        }
    cout << br_novcanica << endl;
    //cout << broj_cifara << endl;
    return 0;
}