a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
A = a % 10 +1
B = b % 10 +1
C = c % 10 +1
D = d % 10 +1
E = e % 10 +1
M = min([A,B,C,D,E])
L = M - 1
print((a+b+c+d+e)+(A+B+C+D+E)-L)
