# Read the input as integers nums = list(map(int, input().split())) total = 0 for num in nums: if num % 15 == 0: total += 8 elif num % 3 == 0: total += 4 elif num % 5 == 0: total += 4 else: total += len(str(num)) print(total)