#include<stdio.h>
#include<stdlib.h>
#define MAX 1000
void initialize();
int isEmpty();
void push(int);
int pop();
int S[MAX],top;
int main() {
	int x,a,b;
	char s[MAX];
	initialize();
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			b = pop();
			a = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			b = pop();
			a = pop();
			push(a*b);
		}
		else {
			x = atoi(s);
			push(x);
		}
	}
	printf("%d", pop());
	printf("\n");

	return 0;
}
void initialize() {
	top = 0;
}
int isEmpty() {
	if (top == 0) {
		return 1;
	}
	else {
		return 0;
	}
 }
int isFull() {
	if (top >= MAX - 1) {
		return 1; 
	}
	else
	{
		return 0;
	}
}
void push(int x) {
	if (isFull()) {
		fprintf(stderr, "入れれません");
	}
	else
	{
		top++;
		S[top] = x;
	}
}
int pop() {
	if (isEmpty()) {
		fprintf(stderr, "アンダーフロー");
		exit(0);
	}
	else {
		top--;
		return S[top + 1];
	}
}
