class BinHeap
  def initialize(n,buf=nil,max=nil)
    @size=n
    @buf=buf||Array.new(n)
    @max=max||1
  end
  def add(n)
#    print :add_s,n
    a=@buf[i=@max]=n
    @max+=1
    while i>1 && a>b=@buf[i/2]
      @buf[i],@buf[i/2]=b,a
      i/=2
    end
#    print :add_e,n
  end
  def get
#    print :get_s
    ret=@buf[1]
    a=@buf[i=1]=@buf[l=@max-=1]
    while (c=i*2)<l
      c+=1 if c+1<l && @buf[c]<@buf[c+1]
      if a<b=@buf[c]
        @buf[c],@buf[i]=a,b
        i=c
      else
        break
      end
    end
#    print :get_e,ret
    ret
  end
  def dup
    BinHeap.new(@size,@buf.dup,@max)
  end
  def buf
    @buf
  end
  def print(*arg)
    p arg*" "
    i=s=1
    while i<@max
      p @buf[i,s]
      i+=s
      s*=2
    end
  end
end

pq=BinHeap.new(2000000)
while gets
  op,arg = $_.split
  case op
  when "insert"
    pq.add arg.to_i
  when "extract"
    p pq.get
  when "end"
  end
end