#include <stdio.h>
#include <stdlib.h>
#define MAX_N 200

int top, a[MAX_N];

void push(int x)
{
	a[top + 1] = x;
	top++;
}
int pop(void)
{
	int tmp = a[top];
	a[top] = 0;
	top--;
	return tmp;
}

int main(void)
{
	char c;
	top = 0;

	while (scanf("%s ", &c) == 1) {
		int a, b;
		if (c == '+') { 
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (c == '-') {
			a = pop();
			b = pop();
			push (b - a);
		}
		else if(c == '*') {
			a = pop();
			b = pop();
			push (b*a);
		}
		else push(atoi(c));
	}

	printf("%d\n", pop);

    return 0;
}