import math

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

a_1 = int(a[-1])
b_1 = int(b[-1])
c_1 = int(c[-1])
d_1 = int(d[-1])
e_1 = int(e[-1])

m = min(a_1, b_1, c_1, d_1, e_1)
ans = 0

if a_1 == m:
    ans = math.ceil(int(b) / 10) * 10 + math.ceil(int(c) / 10) * 10 + math.ceil(int(d) / 10) * 10 + math.ceil(int(e) / 10) * 10 + int(a)
elif b_1 == m:
    ans = math.ceil(int(a) / 10) * 10 + math.ceil(int(c) / 10) * 10 + math.ceil(int(d) / 10) * 10 + math.ceil(int(e) / 10) * 10 + int(b)
elif c_1 == m:
    ans = math.ceil(int(b) / 10) * 10 + math.ceil(int(a) / 10) * 10 + math.ceil(int(d) / 10) * 10 + math.ceil(int(e) / 10) * 10 + int(c)
elif d_1 == m:
    ans = math.ceil(int(b) / 10) * 10 + math.ceil(int(c) / 10) * 10 + math.ceil(int(a) / 10) * 10 + math.ceil(int(e) / 10) * 10 + int(d)
else:
    ans = math.ceil(int(b) / 10) * 10 + math.ceil(int(c) / 10) * 10 + math.ceil(int(d) / 10) * 10 + math.ceil(int(a) / 10) * 10 + int(e)

print(ans)
