#include <stdio.h>
#include <stdlib.h>
#define SIZE 100
int Stack[SIZE];
int Top = 0;

void push(int number){
  Stack[Top] = number;
  Top++;
}
int pop(void){
  Top--;
  return Stack[Top];
}

int main(){

  int num, cal1, cal2;
  int i = 0;
  char moji[SIZE];
  
  while(scanf("%s",moji) != EOF){
    if(moji[0]== '+'){
      //スタックからのデータ取り出し
      cal1 = pop();
      cal2 = pop();
      //データ挿入
      push(cal1+=cal2);
    }
    else if(moji[0] == '-'){
      cal1 = pop();
      cal2 = pop();
      push(cal2-=cal1);
    }
    else if(moji[0] == '*'){
      cal1 = pop();
      cal2 = pop();
      push(cal1*=cal2);
    }
    else{
      //数字に変換 スタックに格納(push)
      num = atoi(moji);
      push(num);
    }
  }
  printf("%d\n",pop());
  
  return 0;
}
