#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array
#define vt vector

const int mxN=5e5;
string str;
int t, n, ma=0, mi=mxN;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	stack<int> minus;
	while(n--) {
		cin >> str;
		if(str=="PUSH") {
			cin >> t;
			if(minus.empty())
				minus.push(t);
			else
				minus.push(min(minus.top(), t));
		}
		else if(str=="POP") {
			if(minus.empty())
				cout << "EMPTY\n";
			else
				minus.pop();
		}
		else {
			if(minus.empty())
				cout << "EMPTY\n";
			else
				cout << minus.top()  << "\n";
		}
	}
}
