num = input() n_moji = len(num) ana = {a: b for a, b in zip("0123456789", [1,0,0,0,1,0,1,0,2,1])} n_ana = sum(ana[c] for c in num) print(min([n_moji * 2 + n_ana + 1, (n_ana + 1)*2 + n_moji]))