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

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

int top = 0;
int array[MAX];

int main(){
  int x,y;
  char num[MAX];
  while(scanf("%s",num) != EOF){
 
    if(num[0] == '+'){
      x = pop();
      y = pop();
      push(x + y);
    }

    else if(num[0] == '-'){
      x = pop();
      y = pop();
      push(y - x);
    }

    else if(num[0] == '*'){
      x = pop();
      y = pop();
      push(x * y);
    }

    else{
      x = atoi(num);
      push(x);
    }
   
  }
  
  printf("%d\n",array[0]);
  return 0;
}

void push(int x){
  if(top == MAX) exit(2);  
  array[top] = x;
  top++;
}

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

}

