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