print((function (f, s) return f(s) end)(function (s) local h,a,b = { ["0"]=1;["4"]=1;["6"]=1;["8"]=2;["9"]=1; ["1"]=0;["2"]=0;["3"]=0;["5"]=0;["7"]=0; },#s*2+1,#s+2 for i=1,#s do local n=h[s:sub(i,i)] a,b = a+n,b+2*n end return a < b and a or b end, io.stdin:read("*l")))