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