# B
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
 
print(A+B+C+D+E+a+b+c+d+e-max([a,b,c,d,e]))