A = list(map(int, input().split())) S = 0 for N in A: if N % 15 == 0: S += 8 elif N % 3 == 0 or N % 5 == 0: S += 4 else: S += len(str(N)) print(S)