a = list(map(int,[input() for i in range(5)]))
b = []
c =[]
d = False
for i in a:
	b.append(10-i % 10)
for i,j in zip(b,a):
	if max(b) != i:
		c.append(i+j)
	elif not d:
		c.append(j)
	else:
		c.append(i+j)
print(sum(c))
