a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
a1 = 10 - a%10
b1 = 10 - b%10
c1 = 10 - c%10
d1 = 10 - d%10
e1 = 10 - e%10
l = [a1,b1,c1,d1,e1]

for i in range(5):
  if l[i] == 10:
    l[i] = 0
  
def max(x,y):
  if x <= y:
    return y
  else:
    return x
f = max(max(max(max(l[0],l[1]),l[2]),l[3]),l[4])

ans = (a+b+c+d+e) + (a1+b1+c1+d1+e1) - f
print(ans)
