#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; // 4: 1, 6: 1, 8: 2, 9: 1 int f(int n){ if(n == 0 || n == 4 || n == 6 || n == 9){ return 1; }else if(n == 8){ return 2; } return 0; } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); string S; std::cin >> S; int n = S.size(); int hole = 0; for(char &c : S){ int x = c - '0'; hole += f(x); } int res = min(2 * (1 + hole) + n, 2 * n + (1 + hole)); std::cout << res << std::endl; }