import java.util.*;
class MyStack1 {
private Stack<Integer> stackData;
private Stack<Integer> stackMin;
public MyStack1() {
this.stackData = new Stack<Integer>();
this.stackMin = new Stack<Integer>();
}
public void push(int newNum) {
if (this.stackMin.isEmpty()) {
this.stackMin.push(newNum);
} else if (newNum <= this.getmin()) {
this.stackMin.push(newNum);
}
this.stackData.push(newNum);
}
public int pop() {
if (this.stackData.isEmpty()) {
throw new RuntimeException("Stack is empty");
}
//获取值不能用pop,pop是弹出,要用peek
int value = this.stackData.peek();
if (value == this.getmin()) {
//如果弹出栈的元素是最小值,那min栈也要弹出第一个元素,修改记录的最小值
this.stackMin.pop();
}
this.stackData.pop();
return value;
}
public int getmin() {
//如果栈为空,抛出非首检异常
if (this.stackMin.isEmpty()) {
throw new RuntimeException("stackmin is empty");
}
//不为空,就返回最小值,stackmin的是存最小值的栈
return this.stackMin.peek();
}
}
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
MyStack1 stack1 = new MyStack1();
int t = scan.nextInt();
for(int i=0;i<t;i++){
String op=scan.next();
if(op.equals("push")){
int x= scan.nextInt();
stack1.push(x);
}else if(op.equals("getMin")){
System.out.println(stack1.getmin());
}else if(op.equals("pop")){
stack1.pop();
}
}
}
}