A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = []
a.append(10-(A % 10))
a.append(10-(B % 10))
a.append(10-(C % 10))
a.append(10-(D % 10))
a.append(10-(E % 10))
b = []
for i in range(5):
    if a[i] != 10:
        b.append(a[i])
c = A+B+C+D+E+sum(b)-max(b)
print(c)