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

dis_a = 10 - a % 10 
dis_b = 10 - b % 10
dis_c = 10 - c % 10
dis_d = 10 - d % 10
dis_e = 10 - e % 10

time = {"a":a, "b":b, "c":c, "d":d, "e":e}
dic = {"a":dis_a, "b":dis_b, "c":dis_c, "d":dis_d, "e":dis_e}

for k,v in dic.items():
	if v == 10 :
		dic[k] = 0


new = {}
for k, v in sorted(dic.items(), key=lambda x: x[1]):
    new[k] = v

ans = 0
for i in range(4):
	ans += time[list(new.keys())[i]] + list(new.values())[i]

ans += time[list(new.keys())[4]]

print(ans)