#include <stdio.h>
#include <string.h>
#include <stdlib.h>

class Stack
{
public:
	void push(int x)
	{
		++myTop;
		myData[myTop] = x;
	}
	void pop()
	{
		--myTop;
	}
	int top()
	{
		int nTemp = myData[myTop];
		return nTemp;
	}
private:
	int myTop = 0;
	int myData[1000] = { 0 };
};


int main()
{
	char chIn[100] = { '\0' };
	Stack staIn;
	int nTemp = 0;
	int na = 0, nb = 0;

	while (scanf_s("%s", chIn, 100))
	{
		if (chIn[0] - '0' <= 9 && chIn[0] - '0' >= 0)
		{
			nTemp = atoi(chIn);
			staIn.push(nTemp);
		}
		else
		{
			nb = staIn.top();
			staIn.pop();
			na = staIn.top();
			staIn.pop();
			switch (chIn[0])
			{
			case '-':
				staIn.push(na - nb);
				break;
			case '+':
				staIn.push(na + nb);
				break;
			case '*':
				staIn.push(na * nb);
				break;
			}
		}
	}
	int nout = staIn.top();
	printf("%d\n", staIn.top());
	return 0;
}
