#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

// Headers
string toString (double);
int toInt (string);
double toDouble (string);

int main() {
    int v;
    int c;
    int s;
    int m;
    
    cin >> v;
    s = 0;
    v = fabs(v);
    while (v > 0) {
        c = v % 10;
        m = 2;
        if (c == 0) {
            m = 0;
        } else {
            if (c <= 2) {
                m = 1;
            } else {
                if (c == 5) {
                    m = 1;
                } else {
                    if (c >= 8) {
                        m = 3;
                    }
                }
            }
        }
        s = s + m;
        v = (double) v / 10;
    }
    cout << s << endl;
    return 0;
}

// The following implements type conversion functions.
string toString (double value) { //int also
    stringstream temp;
    temp << value;
    return temp.str();
}

int toInt (string text) {
    return atoi(text.c_str());
}

double toDouble (string text) {
    return atof(text.c_str());
}