```
public class MinStack {
/** initialize your data structure here. */
Stack stack;
Stack min;
int minv;
public MinStack() {
minv = Integer.MAX_VALUE;
stack = new Stack();
min = new Stack();
}
public void push(int x) {
minv = Math.min(minv, x);
min.push(minv);
stack.push(x);
}
public void pop() {
stack.pop();
min.pop();
}
public int top() {
return (int)stack.peek();
}
public int getMin() {
return (int)min.peek();
}
```

}