#include <stdio.h>

using namespace std;

int brciff(long long int n) {
    int brcif = 0;
    while(n > 0) {
        brcif++; n /= 10;
    }
    return brcif;
}

int st(long long int st) {
    int vr = 1;
    for(int i = 0; i < st; i++) vr *= 10;
    return vr;
}

int main() {
   long long int n; int br = 0;
    scanf("%lld", &n);
    long long int t = n;
    for(int i = brciff(n) - 1; i >= 0; i--){
        while(5 * st(i) <= t) { t = t - 5 * st(i); br++;}
        while(2 * st(i) <= t) { t = t - 2 * st(i); br++;}
        while(1 * st(i) <= t) { t = t - 1 * st(i); br++;}
    }
    printf("%d", br);
    return 0;
}