#include <cmath> #include <vector> #include <list> #include <map> #include <set> #include <functional> #include <queue> #include <iostream> #include <string.h> #include <iomanip> #include <algorithm> #include <functional> #include <cstdint> #include <climits> #include <unordered_set> #include <sstream> #include <stack> using namespace std; typedef long long int ll; typedef pair<int,int> pii; typedef tuple<int,int,int> t3; using namespace std; string s; map<char,int> c; int get1() { int count = (int)s.length() * 2; count++; for(auto e : s) { count += c[e]; } return count; } int get2() { int count = (int)s.length(); count+=2; for(auto e : s) { count += c[e]*2; } return count; } int main(){ cin >> s; c['0'] = 1; c['1'] = c['2'] = c['3'] = 0; c['4'] = 1; c['5'] = 0; c['6'] = 1; c['7'] = 0; c['8'] = 2; c['9'] = 1; cout << min(get1(), get2()) << endl; return 0; }