n = input() m = [1,0,0,0,1,0,1,0,2,1] mm = sum([m[ord(i)-ord('0')]for i in n]) ans = min(mm*2+2+len(n),len(n)*2+mm+1) print(ans)