a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

time = [[a, a%10], [b, b%10], [c, c%10], [d, d%10], [e, e%10]]
ans = 0

for i in range(5):
	if time[i][1] == 0:
		time[i][1] = 10
		
time = sorted(time, key = lambda x:x[1], reverse = True)

for i in range(4):
	ans += time[i][0] + (10 - time[i][1])
	
print(ans + time[4][0])
print(ans + time[4][0])