T = [int(input()) for _ in range(5)]

MaxTime = 0
for t in T:
	MaxTime += ((t + 9) // 10) * 10

MaxDiffTime = 9
for t in T:
	if t % 10 != 0:
		MaxDiffTime = min(MaxDiffTime, t % 10)

print(max(0, MaxTime - (10 - MaxDiffTime)))
