#include <stdio.h>
#define N 2000000
void insert(int);
void heapIncreaseKey(int *,int,int);
int ExtractMax(int *);
void maxHeapify(int *,int);

int Heap,A[N];

int main(){
  int aaa;
  char bbb[20];

  while(1){
    scanf("%s",bbb);
    if(bbb[0]=='e'&&bbb[1]=='n')
      break;
    if(bbb[0]=='i'){
      scanf("%d",&aaa);
      insert(aaa);
    }
    else{
      printf("%d\n",ExtractMax(A));
    }
  }
  return 0;
}
void insert(int aaa){
  Heap++;
  A[Heap]=-3;
  heapIncreaseKey(A,Heap,aaa);
}
void heapIncreaseKey(int *A,int i,int aaa){
  int m;
  if(aaa<A[i])
    return;
  A[i]=aaa;
  while(i>1&&A[i/2]<A[i]){
    m=A[i];
    A[i]=A[i/2];
    A[i/2]=m;
    i=i/2;
  }
}
int ExtractMax(int *A){
  int max;
  if(Heap<1)
    return -3;
  max=A[1];
  A[1]=A[Heap];
  Heap--;
  maxHeapify(A,1);
  return max;
}
void maxHeapify(int *A,int i){
  int l,r,largest,m;
  l=2*i;
  r=2*i+1;

  if(l<=Heap && A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=Heap && A[r]>A[largest])
    largest=r;
  if(largest!=i){
    m=A[i];
    A[i]=A[largest];
    A[largest]=m;
    maxHeapify(A,largest);
  }
}
	  

