#include <stdio.h>

int main(){
  int dat[1024];
  int max = 0;
  int itr;
  int cnt;
  char str[8];
  int num;
  while(1){
    scanf("%s", &str);
    if (strcmp(str, "insert") == 0){
      cnt++;
      scanf("%d", &num);
      if (num > max){
        int i;
        for (i = 0; i < cnt; i++){
          int tmp;
          if(dat[i] < num) continue;
          if(dat[i] >= num){
            int j = i+1;
            tmp = dat[j];
            dat[j] = num;
            for (;j<=cnt;j++){
              int tmp2;
              tmp2 = dat[j];
              dat[j] = tmp;
              tmp = tmp2;
              //dat[j+1] = dat[j];
            }
          }
        }
      }
      dat[itr] = num;
    } else if ( strcmp(str, "extract") == 0){
      printf("%d\n", max);
      cnt --;
    } else return 0;
  }
  return 0;
}