A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = 10 - (A % 10)
b = 10 - (B % 10)
c = 10 - (C % 10)
d = 10 - (D % 10)
e = 10 - (E % 10)
f = max(a, b, c, d, e)
print(A + B + C + D + E + a + b + c + d + e - f)