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

int sp = 0;
int stack[1000];

void show(){
	int i;
	for(i = 0; i < sp; i++){
		printf("%d ",stack[i]);
	}
	printf("\n");
}

int main(void){
	int i;
	char input[100000];
	fgets(input, sizeof(input), stdin);
	for(i = 0 ;input[i] != '\n'; i++){
		switch(input[i]){
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
			stack[sp] = (input[i++] - '0');
			while(input[i] >= '0' && input[i] <= '9'){
				stack[sp] = stack[sp]*10 + (input[i++] - '0');
			} 
			sp++;
			break;

			case '+':
				sp -= 2;
				stack[sp] = stack[sp] + stack[++sp];
				break;

			case '-':
				sp -= 2;
				stack[sp] = stack[sp] - stack[++sp];
				break;

			case '*':
				sp -= 2;
				stack[sp] = stack[sp] * stack[++sp];
				break;
			default:
				break;
		}
	}
	printf("%d\n",stack[0]);
	return 0;
}