A = list(map(int, input().split())) ans = 0 for i in range(len(A)): if A[i] % 5 == 0 and A[i] % 3 == 0: ans += 8 elif A[i] % 5 == 0 or A[i] % 3 == 0: ans += 4 else: ans += len(str(A[i])) print(ans)