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

int top=0, S[1000];

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

int main() 
{
	int far, sec, x, sol=0;
	char fm[100];
	while(scanf("%s",fm) != EOF) {
		if(fm[0] == '+') {
			far = pop();
			sec = pop();
			sol = far + sec;
			push(sol);
		} else if (fm[0] == '-') {
			sec = pop();
			far  = pop();
			sol = far - sec;
			push(sol);
		} else if (fm[0] == '*') {
			far = pop();
			sec = pop();
			sol = far*sec;
			push(sol);
		} else {
			x = atoi(fm);
			push(x);
		}
	}
	printf("%d\n", pop());

	return 0;
}

void push(int x){
   ++top;
   S[top] = x;
}

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