#include<stdio.h>
#include<string.h>
#define Max 2000000
#define Infty (1<<30)

int H,A[Max+1];

void maxheap(int i){
  int l,r,max,tmp;
  l=2*i;
  r=2*i+1;

  if(l <= H && A[l]>A[i])max=l;
  else max=i;
  if(r<=H && A[r]>A[max])max=r;

  if(max!=i){
    tmp=A[i];A[i]=A[max];A[max]=tmp;
    maxheap(max);
  }
}
int extract(){
  int m;
  if(H<1)return -Infty;
  m=A[1];
  A[1]=A[H--];
  maxheap(1);
  return m;
}
void inckey(int i,int key){
  int tmp;
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2] < A[i]){
    tmp=A[i];A[i]=A[i/2];A[i/2]=tmp;
    i=i/2;
  }
}
void insert(int k){
  H++;
  A[H]=-Infty;
  inckey(H,k);
}


int main(){
  int key;
  char com[10];

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

  return 0;
}






