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