#include<stdio.h>
#include<string.h>
#define H 2000000

int n,A[H+1];
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l,r,x,largest;
  l=left(i);
  r=right(i);
  if(l<=n && A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=n && A[r]>A[largest])
    largest=r;
  if(largest!=i){
    x=A[i];
    A[i]=A[largest];
    A[largest]=x;
    maxHeapify(largest);
  }
}

int heapExtractMax(){
  int max;
  if(n<1)
    return -1;
  max=A[1];
  A[1]=A[n];
  n--;
  maxHeapify(1);
  return max;
}
void heapIncreaseKey(int i,int key){
  int x;
  if(key<A[i])
    return;
  A[i]=key;
  while(i>1 && A[parent(i)]<A[i]){
    x=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=x;
    i=parent(i);
  }
}
void maxHeapInsert(int key){
  n=n+1;
  A[n]=-1;
  heapIncreaseKey(n,key);
}
int main(){
  int i,k,x;
  char com[20];

  while(1){
    scanf("%s",&com);
    
    if(strcmp(com,"end")==0)
      break;
    if(com[0]=='i'){
      scanf("%d",&k);
      maxHeapInsert(k);
    }
    else if(com[0]=='e'){
      x=heapExtractMax();
      if(x!=-1)
	printf("%d\n",x);
    }
  }
  return 0;
}