#include <stdio.h>
#include <string.h>
#define INF 100000
#define Com 2000000
int A[Com];
int s=0;

void insert(int);
void increaseKey(int,int);
int extractMax();
void maxHeapify(int);

int main(){

  char c[10];
  int k;
  while(1){
    scanf("%s",c);
    if(strcmp(c,"insert")==0){
      scanf("%d",&k);
      insert(k);
    }
    else if(strcmp(c,"extract")==0){
      printf("%d\n",extractMax());
    }

    else if(strcmp(c,"end")==0) break;
  }

  return 0;
}

void insert(int k){
  s++;
  A[s]=-INF;
  increaseKey(s,k);
 
}

void increaseKey(int i,int k){
  int a;

  A[i]=k;
  while(i > 1 && A[i] > A[i/2]){
    a=A[i];
    A[i]=A[i/2];
    A[i/2]=a;
    i=i/2;
  }
}

int extractMax(){
  int max;

  max=A[1];
  A[1]=A[s];
  s--;
  maxHeapify(1);
  return max;
}

void maxHeapify(int i){
 int l,r;
  int largest;
  int t;

  l=2*i;
  r=2*i+1;


  if(l <= s && A[l] > A[i]){
    largest=l;
  }
  else {
    largest=i;
  }

  if(r <=s && A[r] > A[largest]){
    largest=r;
  }

  if(largest!=i){
    t=A[i];
    A[i]=A[largest];
    A[largest]=t;
    maxHeapify(largest);
  }
}