#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int INF = 1000000007; const double PI = acos(-1.0); typedef long long ll; int main() { string str; int cnt1 = 0, cnt2 = 0, sum0 = 0; cin >> str; for (int i = 0; i < str.length(); i++) { int tmp = str[i] - 48; switch (tmp) { case 0: case 4: case 6: case 9: sum0 += 1; break; case 8: sum0 += 2; break; } } cnt1 = 2 * str.length() + sum0 + 1; cnt2 = 2 * (sum0 + 1) + str.length(); cout << min(cnt1, cnt2) << endl; }