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