#include <iostream>
#include <cmath>

using namespace std;

int brCifara(long long int v){
    int n = 1;
    while(v >= 10) {
        n++;
        v/=10;
    }
    return n;
}

long long int razlaganje(long long int n) {
    long long int br = 0;
    while(n > 0) {
        if(n >= 5) n -= 5;
        else if(n >= 2) n -= 2;
        else if(n == 1) n -= 1;
        br++;
    }
    return br;
}

int main()
{
    long long int V,temp,n = 0,brCif;

    cin >> V;
    
    brCif = brCifara(V);

    for(int i = 0; i < brCif; ++i) {
        temp = V%10;
        V = V - temp;
        V /= 10;
        n += razlaganje(temp);
    }

    cout << n;

    return 0;
}