import java.util.Stack;
public class Solution {
private Stack<Integer> stack1 = new Stack<>();
private Stack<Integer> stack2 = new Stack<>();
public void push(int node) {
if (stack1.isEmpty()) {
stack1.push(node);
stack2.push(node);
} else {
int val = stack2.peek();
if (val < node) {
stack2.push(val);
} else {
stack2.push(node);
}
stack1.push(node);
}
}
public void pop() {
if (stack1.isEmpty()) {
throw new RuntimeException("The stack is empty");
}
stack1.pop();
stack2.pop();
}
public int top() {
if (stack1.isEmpty()) {
throw new RuntimeException("The stack is empty");
}
return stack1.peek();
}
public int min() {
if (stack2.isEmpty()) {
throw new RuntimeException("The stack is empty");
}
return stack2.peek();
}
}