
#include <stack>
#include <iostream>
#include <sstream>
#include <string>
#include <iterator>
#include <algorithm>

using namespace std;

void process_token(const string&s, stack<int>&stack)
{
	if (s == "q")
		exit(0);
	if (s == "p") {
		if (!stack.empty()) cout << stack.top() << endl;
		else cout << "Empty Stack!" << endl;
		return;
	}

#define processOp(op)\
	if (s == #op) {\
		if (stack.size() >= 2) {\
			int l = stack.top();\
			stack.pop();\
			int r = stack.top();\
			stack.pop();\
			stack.push(l op r);\
		}\
		else {\
			cerr << "Not enough values for" #op << endl;\
		}\
		return;\
	}


	processOp(+)
	processOp(-)
	processOp(*)
	processOp(/ )

#undef processOp

		//it must have been an integer.
		stringstream ss(s);
	int int_temp;
	ss >> int_temp;

	stack.push(int_temp);

}

int main()
{
	stack<int> stack;

	for_each(istream_iterator<string>(cin), istream_iterator<string>(),
			[&stack](string s) {process_token(s, stack); });

	return 0;
}
