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