#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; #define debug(x) cerr << #x << " = " << (x) << endl; #define mod 1000000007 //1e9+7(prime number) #define INF 1000000000 //1e9 #define LLINF 2000000000000000000LL //2e18 #define SIZE 100010 int main(){ int p[] = {1,0,0,0,1,0,1,0,2,1}; int n; scanf("%d",&n); if(n == 0){ puts("4"); return 0; } int ans = 1, ans2 = 2; while(n > 0){ ans += p[n%10] + 2; ans2 += p[n%10]*2+1; n/=10; } printf("%d\n",min(ans,ans2)); return 0; }