a=[]
for i in range(5):
	a.append(int(input()))
b=[]
for i in range(5):
	b.append((10-a[i]%10,i))
c=[]
for i in range(5):
	c.append(b[i][0]+a[i])
b.sort()
t=b[4][1]
ans=0
for i in range(5):
	if i !=t:
		ans+=c[i]
ans+=a[t]
print(ans)