W = [1,0,0,0,1,0,1,0,2,1]
n = input()
w = sum(W[i] for i in map(int,n)) + 1
b = len(n)
print(min(w,b)*2+max(w,b))