import itertools

L=[ input() for i in range(5)]

P=list(itertools.permutations( range(5) ))
ans=float("inf")

for p in P:
	t=0
	for idx, x in enumerate(p):
		t+=L[x]
		if t%10!=0 and idx!=4 :
			t+=10- (t%10)
	ans=min(ans,t)

print ans
