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