#include<stdio.h>
#include<stdlib.h>
#define SIZE 100

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

int stack[SIZE];
int top = 0;

int main(){
  char data;
  int num,status,i,j,k,count = 0;

  while(1){
    status = scanf("%c",&data);
    if(status != 1) break;
    if(data == ' '){
       count = 0;
       continue;
     }
    if(data <= '9' && data >= '0'){
      num = data - 48;
      count++;
      if(count >= 2){
        num = pop()*10 + num;
      }
       push(num);
     }

    if(data == '+' || data == '-' || data == '*'){
      count = 0;
      i = pop();
      j = pop();
      if(data == '+') k = j + i;
      if(data == '-') k = j - i;
      if(data == '*') k = j * i;
      push(k);
    }
  }
  printf("%d\n",stack[0]);
  return 0;
}

void push(int data){
  if(top == SIZE) exit(2);
  stack[top] = data;
  top++;
}

int pop(void){
  if(top == 0) exit(3);
  top--;
  return stack[top];
}

