#include int main() { int n; scanf("%d", &n); if (n == 0) { printf("4\n"); return 0; } int ho[10] = { 1,0,0,0,1,0,1,0,2,1 }; int ans = 1, m = n; while (n > 0) { ans += 2 + ho[n % 10]; n /= 10; } int ans1 = 2; n = m; while (n > 0) { ans1 += 1 + 2 * ho[n % 10]; n /= 10; } if (ans > ans1) ans = ans1; printf("%d\n", ans); return 0; }