#include <stdio.h>
int main(){
  int i,max,hozon,count=0;
  char com[20];
  int S[2000000];

  while(1){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&S[count]);
      count++;
    }
    if(com[0] == 'e' && com[1] == 'x'){
      for(i=0;i<=count;i++){
	if(i==0){
	  max = S[i];
	}
	else if(S[i]>=max){
	  max = S[i];
	  hozon = i;
	}
      }
      printf("%d\n",max);
      S[hozon] = 0;
    }
    if(com[0] == 'e' && com[1] == 'n'){
      break;
    }
  }
  return 0;
    
}

