#include <stdio.h>
#include <stdlib.h>

#define N 10000

int H=0,A[2000000001];

void maxHeapify(int k){
  int v,l,r,z;
  l=k*2;
  r=k*2+1;
  z=k;
  if(l<=H&&A[l]>A[k]) z=l;
  else z=k;
  if(r<=H&&A[r]>A[z]) z=r;

  if(z!=k){
    v=A[k];
    A[k]=A[z];
    A[z]=v;
    maxHeapify(z);
  }
}

int extract(){
  int m;
  if(H<1)return -N;
  m=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return m;
}

void t(int a,int b,int i){
  A[i/2]=a;
  A[i]=b;
  return;
}

void upheap(int i, int k) { 
    int v;
    if(k<A[i]) return;
    A[i]=k;
    while(i > 1 && A[i/2]<A[i]) {
      t(A[i],A[i / 2],i);
        i = i / 2;
    }
}


void insert(int k) {
  H++;
    A[H] = -N;
    upheap(H,k);
}

int main() {

  int i,a;
  char c[10];


    while(1){
      scanf("%s",c);
      if(c[0]=='e'&&c[1]=='n')break;
      if(c[0]=='i'){
	scanf("%d",&a);
	insert(a);
      }
      else printf("%d\n",extract());
    }
   
    return 0;
}

