#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { string s; cin >> s; int n = s.length(); int a = 0; for ( int i = 0; i < n; i++ ) { if ( s[i] == '0' || s[i] == '4' || s[i] == '6' || s[i] == '9' ) { a++; } else if ( s[i] == '8' ) { a += 2; } } if ( n < a+1 ) { cout << n*2+a+1 << endl; } else { cout << (a+1)*2+n << endl; } return 0; }