#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long signed main(){ int n; cin >> n; int cnt = 0, ana = 0; while(n > 0){ if(n % 10 == 6 || n % 10 == 9 || n % 10 == 0 || n % 10 == 4) ana++; if(n % 10 == 8) ana += 2; n /= 10; cnt++; } cout << min(2 * cnt + ana + 1, 2 * (ana + 1) + cnt) << endl; return 0; }