a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = [a%10,b%10,c%10,d%10,e%10]
m = min(s)
if a%10 == m:
    ans = a + int(b/10)*10+int(c/10)*10+int(d/10)*10+int(e/10)*10+40
elif b%10 == m:
    ans = b + int(a/10)*10+int(c/10)*10+int(d/10)*10+int(e/10)*10+40
elif c%10 == m:
    ans = c + int(b/10)*10+int(a/10)*10+int(d/10)*10+int(e/10)*10+40
elif d%10 == m:
    ans = d + int(b/10)*10+int(c/10)*10+int(a/10)*10+int(e/10)*10+40
else:
    ans = e + int(b/10)*10+int(c/10)*10+int(d/10)*10+int(a/10)*10+40
print(ans)