#include <iostream>
#include <stack>	
#include <string>	
#include <cctype>	

using namespace std;

int main()
{
	int i;
	char inputEx[128];
	char token;
	int value, value1, value2;
	stack<char> myStack;

	cout << "Please enter the RPN inputEx to be evaluated: " << endl <<
		"(Note: Input must end with an equals sign (=))"
		<< ": " << endl;
		
	cin.getline(inputEx, 128);
  
	i = 0;
	
	for(i=0; inputEx[i]!='='; i++)
	{
		token = inputEx[i];
		
		if(token == ' ') continue;
		
		if (isdigit(token))
		{
			value = token - '0';
			myStack.push(value);
		}
		else
		{
			value2 = myStack.top();
			myStack.pop();
			value1 = myStack.top();
			myStack.pop();
			switch(token)
			{
				case '+': value = value1 + value2;
				break;
				case '-': value = value1 - value2;
				break;
				case '*': value = value1*value2;
				break;
				case '/': value = value1/value2;
				break;
			}
			myStack.push(value);
		}
	}
	
	value = myStack.top();
	myStack.pop();
	
	cout << inputEx << " " << value << endl;
	cout << endl;
	
	return 0;
}