a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

num = []
num.append(a%10)
num.append(b%10)
num.append(c%10)
num.append(d%10)
num.append(e%10)

ans = min(num)
x = 10
if min(num) == 0:
  if a%10 != 0 and b%10 != 0 and a%10 > b%10:
    x = b%10
  if b%10 != 0 and c%10 != 0 and x > c%10:
    x = c%10
  if c%10 != 0 and d%10 != 0 and x > d%10:
    x = d%10
  if d%10 != 0 and e%10 != 0 and x > e%10:
    x = e%10
  sum = a+(10-a%10) + b+(10-b%10) + c+(10-c%10) + d+(10-d%10) + e+(10-e%10)-30+x
else:  
  sum = a+(10-a%10) + b+(10-b%10) + c+(10-c%10) + d+(10-d%10) + e+(10-e%10)-10+ans

print(sum)