def binarySearch(a, i, left, right)
  if left == right then
    return left
  end
  middle = (right + left)/2
  if a[middle] == i
    return middle
  elsif a[middle] > i
    return binarySearch(a, i, middle+1, right)
  else
    return binarySearch(a, i, left, middle)
  end
end

a = []
loop do
  cmd, num = gets.split
  case cmd;
  when "insert";
    idx = binarySearch(a, num.to_i, 0, a.size)
    a.insert(idx, num.to_i)
  when "extract";
    puts a.shift()
  when "end";
    break
  end
end