#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stack>
using namespace std;
stack <int>reversh_polish;//不返回值
int main(void)
{
	int a, b;
	char s[100];

	while (scanf("%s", s) != EOF)
	{
		if (s[0] == '+')
		{
			a = reversh_polish.top();
			reversh_polish.pop();
			b = reversh_polish.top();
			reversh_polish.pop();
			reversh_polish.push(a + b);
		}
		else if (s[0] == '-')
		{
			a = reversh_polish.top();
			reversh_polish.pop();
			b = reversh_polish.top();
			reversh_polish.pop();
			reversh_polish.push(b - a);
		}
		else if (s[0] == '*')
		{
			a = reversh_polish.top();
			reversh_polish.pop();
			b = reversh_polish.top();
			reversh_polish.pop();
			reversh_polish.push(b * a);
		}
		else if (s[0] == '/')
		{
			a = reversh_polish.top();
			reversh_polish.pop();
			b = reversh_polish.top();
			reversh_polish.pop();
			reversh_polish.push(a / b);
		}
		else
		{
			reversh_polish.push(atoi(s));
		}
	}
	printf("%d\n", reversh_polish.top());
	//system("pause");
	                                                                           
	return 0;
}
