food = [input() for _ in range(5)]
if len(set(food)) == 1:
  food_check1 = [int(10-int(food[i][-1])) for i in range(1, len(food))]
  food_check2 = [int(i) for i in food]
  print(sum(food_check1) + sum(food_check2))
else:
  check = [int(i[-1]) for i in food if i[-1] != '0']
  food_check1 = [int(i) for i in food if i[-1] != '0']
  food_check2 = [10-int(str(i)[-1]) for i in food_check1 if int(str(i)[-1]) != min(check)]
  food = [int(i) for i in food]
  print(sum(food)+sum(food_check2))