N=input() L,Z=len(N),sum((1,0,0,0,1,0,1,0,2,1)[int(x)]for x in N) print(L+Z+min(Z+2,L+1))