#include <stdio.h>
#include <cmath>

int brojCifara(int V){
    int br = 0;
    while(V > 0){
        V = V / 10;
        br++;
    }
    return br;
}

int stepen(int baza, int exp){
    int br = 1;
    for(int i = 0; i < exp; ++i){
        br *= baza;
    }
    return br;
}

void nizCifara(int V, int cifre[]){
    int i = 0;
    while(V > 0){
        cifre[i] = V % 10;
        V /= 10;
        i++;
    }
}

int main()
{
    const int d[] = {5, 2, 1};
    int V, br, k, pom, i, rez;
    scanf("%i", &V);
    k = brojCifara(V);
    int cifre[k];
    nizCifara(V, cifre);
    br = 0;
    k = 0;
    i = 0;

    while(V > 0){
        pom = cifre[k]*stepen(10, k);
        V -= pom;
        while(pom > 0){
            rez = pom / (d[i]*stepen(10,k));
            br += rez;
            pom -= rez * d[i]*stepen(10,k);
            i++;
        }
        k++;
        i = 0;
    }

    printf("%i", br);
}