#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 - 10;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
stack<int> s;
stack<int> mn;
int n;
cin >> n;
while (n--) {
string x;
cin >> x;
if (x == "push") {
int x;
cin >> x;
s.push(x);
if (mn.empty() || x <= mn.top()) {
mn.push(x);
}
}
else if (x == "pop") {
if (s.empty()) {
cout << "error\n";
} else {
if (s.top() == mn.top()) {
mn.pop();
}
s.pop();
}
}
else if (x == "top") {
if (s.empty()) {
cout << "error\n";
} else {
cout << s.top() << "\n";
}
}
else if (x == "get_min") {
if (mn.empty()) {
cout << "error\n";
} else {
cout << mn.top() << "\n";
}
}
}
}