from operator import itemgetter from itertools import * from bisect import * from collections import * from heapq import * import sys # input=sys.stdin.buffer.readline input=sys.stdin.readline sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(input()) def MI(): return map(int, input().split()) def MI1(): return map(int1, input().split()) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return input()[:-1] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] aa=[1,0,0,0,1,0,1,0,2,1] s=list(map(int,list(SI()))) back=sum(aa[c] for c in s)+1 ans=min(back*2+len(s),back+len(s)*2) print(ans)