#include<stdio.h>
#define MAX 2000009
int n=1;

void maxHeapify(int A[],int i){
  int l,r,largest,change;
  l=i*2;
  r=i*2+1;
  if(l<=n && A[l]>A[i]) largest=l;
  else largest = i;
  if(r<=n && A[r]>A[largest]) largest = r;
  if(largest!=i){
    change=A[i];
    A[i]=A[largest];
    A[largest]=change;
    maxHeapify(A,largest);
    }
}


void heapIncreasekey(int A[],int i,int key){
  int change;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    change=A[i];
    A[i]=A[i/2];
    A[i/2]=change;
    i = i/2;
  }
  
    }

int heapExtractMax(int A[]){
	int max;
	if(n<1) printf("helpunderflow");
	max=A[1];
	n--;
	A[1] = A[n];
	
	maxHeapify(A,1);
	return max;
}



int main(){
  int H[MAX];
  char sen[20];
  int k;
  int max;

  while(1){
    scanf("%s",sen);
    if(sen[0]=='i'){
      scanf("%d",&k);
      heapIncreasekey(H,n,k);
      n++;
    }
    else if(sen[1]=='x'){
      //for(k=1;k<=n;k++) printf("%d ",H[k]);
      //printf("\n");
    printf("%d\n",heapExtractMax(H));
    //for(k=1;k<=n;k++) printf("%d ",H[k]);
    //printf("\n");
      
      //     printf("%d\n",heapExtractMax(H));
     }
    else break;
  }
  //  for(k=1;k<n;k++) printf("%d ",H[k]);
  return 0;
}

