#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int stack[1000];
int top=0;

void push(int);
int pop(void);

int main(){
	char a[100];
	int b,c;

	while(scanf("%s",&a) != EOF){
		if(a[0] == '+'){
			b = pop();
			c = pop();
			push(b+c);
		}else if(a[0] == '-'){
			b = pop();
			c = pop();
			push(b-c);
		}else if(a[0] == '*'){
			b = pop();
			c = pop();
			push(b*c);
		}else{
			push(atoi(a));
		}

		printf("%d\n", pop());
		return 0;
	}
}

void push(int n){
	stack[++top] = n;
}

int pop(){
	top--;
	return stack[top+1];
}