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

#define STACK_SIZE  100   /* ??????????????????????????¨?????§???????????????????????§?????° */
#define SUCCESS     1     /* ?????? */
#define FAILURE     0     /* ??±??? */

typedef int data_t;       /* ??????????????????????????????????????? */

data_t stack_data[STACK_SIZE];  /* ??????????????¬??? */
int stack_num;                  /* ????????????????????????????????° */

//push??¨?????¢??°
int push(data_t push_data)
{
    if (stack_num < STACK_SIZE) {
        stack_data[stack_num] = push_data;
        stack_num ++;
        return SUCCESS;
    } else {
        return FAILURE;
    }
}

//pop??¨?????¢??°
int pop(data_t *pop_data)
{
    if (stack_num > 0) {
        stack_num --;
        *pop_data = stack_data[stack_num];
        return SUCCESS;
    } else {
        return FAILURE;
    }
}
/*
//??¨?????¨?????¢??°
void stackPrint()
{
    int i;

    printf("stack [");
    for (i = 0; i < stack_num; i++) {
        printf("%3d", stack_data[i]);
    }
    printf("]\n");
}*/

int main(void){
    char input[1000000];
	int i,result,ope1,ope2;
	
	stack_num = 0;
	
    while(scanf("%s", input) == 1){	
	
	for(i = 0; i < strlen(input); i++){
		if(input[i]=='*'){
			pop(&ope1); pop(&ope2);
			result = ope2 * ope1;
			push(result);
		}else if(input[i]=='+'){
			pop(&ope1); pop(&ope2);
			result = ope2 + ope1;
			push(result);
		}else if(input[i]=='-'){
			pop(&ope1); pop(&ope2);
			result = ope2 - ope1;
			push(result);
		}else
			push(input[i] - '0');
			
		//stackPrint();
	}
	
    }
	pop(&result);
	printf("%d\n", result);
	
	return 0;
}