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