#include<stdio.h>
#include<string.h>

#define MAX 2000000
#define INFTY 500000000

int P,A[MAX+1];

void maxHeap(int a){
  int l,r,lgest;
  l = 2*a;
  r = 2*a+1;

  if(l<=P && A[l]>A[a])
    lgest = l;
  else lgest = a;
  if(r<=P && A[r]> A[lgest]) lgest = r;

  if(lgest != a){
    int z;
    z = A[a];
    A[a] = A[lgest];
    A[lgest] = z;
    maxHeap(lgest);
  }
}


int ext(){
  int mv;
  if(P<1) return -INFTY;
  mv = A[1];
  A[1] = A[P--];
  maxHeap(1);
  return mv;
}

void incK(int a,int k){

  int w;
  if(k<A[a])return;
  A[a] = k;
  while(a>1&&A[a/2]<A[a]){
    w = A[a];
    A[a] = A[a/2];
    A[a/2] = w;
    a = a/2;
  }
}



void ins(int k){
  P++;
  A[P] = -INFTY;
  incK(P,k);
}



int main(){
  int k;
  char c[10];

  while(1){
    scanf("%s",c);
    if(c[0] == 'e'&&c[1]=='n') break;
    if(c[0] == 'i'){
      scanf("%d",&k);
      ins(k);
    }else{
      printf("%d\n",ext());
    }
  }

  return 0;
}

