#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define INFTY 10000000

int H,A[MAX+1];

void maxheap(int i){
  int left,right,saidai,x;
  left=2*i;
  right=2*i+1;

  if(left<=H && A[left] > A[i])
    saidai=left;
  else saidai=i;

  if(right<=H && A[right] > A[saidai])
    saidai=right;

  if(saidai!=i){
    x=A[i];
    A[i]=A[saidai];
    A[saidai]=x;
    maxheap(saidai);
  }
}

int extract(){
    int maxv;
    if(H<1)return -INFTY;
    maxv=A[1];
    A[1]=A[H--];
    maxheap(1);
    return maxv;
}

void increasekey(int i,int key){
    if(key<A[i])return;
    A[i]=key;
    while(i>1&&A[i/2]<A[i]){
        int t=A[i];
        A[i]=A[i/2];
        A[i/2]=t;
        i=i/2;
    }
}

void insert(int key){
    H++;
    A[H]=-INFTY;
    increasekey(H,key);
}

int main(){
    int key;
    char str[10];
    while(1){
    scanf("%s",str);
    if(str[0]=='e'&&str[1]=='n')break;
    if(str[0]=='i'){
        scanf("%d",&key);
        insert(key);
    }               
    else{
        printf("%d\n",extract());
    }
    }
    return 0;
}

