#$time_i = 0
#$time_e = 0
class Maximum
  def initialize(arr = [nil])
    @arr = arr
    @size = 0
  end
  def insert(key)
    #start = Time.now
    @arr[i = @size += 1] = key = key.to_i
    while i / 2 >= 1 and @arr[i / 2] < key
      @arr[i] = @arr[i / 2]
      i /= 2
    end
    @arr[i] = key
    #$time_i += Time.now - start
  end
  def extract
    #start = Time.now
    puts @arr[1]
    @arr[i = 1] = @arr[@size]
    while i * 2 < @size and @arr[(@arr[i * 2] > @arr[i * 2 + 1]) ? (t = i * 2) : (t = i * 2 + 1)] > @arr[@size]
      @arr[i] = @arr[t]
      i = t
    end
    @size -= 1
    #$time_e += Time.now - start
  end
  def to_s
    @arr.join(" ")
  end
end
def main(input = STDIN)
  heap = Maximum.new
  while (order = input.gets.chomp) != "end"
    heap.send(*order.split(" "))
  end
  #p [$time_i, $time_e]
end
#main(f = File.open('input2.txt'))
#f.close
main