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