#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++;
        }
        //cout << broj_cifara << endl;
        int k = broj_cifara - 1;
        if(v < 2 * stepen10(k)){
            v -= stepen10(k);
            br_novcanica++;
        }
        else if(2 * stepen10(k) <= v && v < 5 * stepen10(k)){
            v -= 2 * stepen10(k);
            br_novcanica++;
        }
        else{
            v -= 5 * stepen10(k);
            br_novcanica++;
        }
    }
    cout << br_novcanica << endl;
    //cout << broj_cifara << endl;
    return 0;
}