// editor5
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 int n,top=-1;
typedef struct stu
{
    int id;
    int pre;
}stu;
void enq()
{int n1,n2;
scanf("%d%d",&n1,&n2);
 stu arr[n];
  int c=++top;
       arr[c].id=n1;
       arr[c].pre=n2;
   
}
void deq()
{ if(top!=-1)
    top--;
    
}
int main()
{
   
    scanf("%d",&n);
    char str[100];
    scanf("%s",str);
    if(strcmp(str,"INSERT")==0)
    {
        enq();
    }
    else if(strcmp(str,"DELETE")==0)
    {
        deq();
    }
    int c=0,max[99];
    max[c]=arr[0].pre;
   for(int i=0;i<=top;i++)
   {
   if(arr[i].pre > max)
   {
       max[c]=arr[i].pre;
       c++;
   }
     
   }
   printf("%d",max[0]) ; 
}