#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); string n; cin >> n; array cnt = { 1, 0, 0, 0, 1, 0, 1, 0, 2, 1 }; int ans = 1e9; { int tmp = 0; tmp += n.size(); for (char c : n) tmp += cnt[c - '0']; tmp += 1; tmp += n.size(); ans = min(ans, tmp); } { int tmp = 0; tmp += 1; for (char c : n) tmp += cnt[c - '0']; tmp += n.size(); for (char c : n) tmp += cnt[c - '0']; tmp += 1; ans = min(ans, tmp); } cout << ans << '\n'; return 0; }