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

int * Include_Number(char *);

#define MAX 398
int main() {
  char stack[MAX];
  int i,j=0;
  int number[100] = {};
  int num;
  int len_number=0;
  char type[99];
  int len_stack;
  int result=0;
  int res[100]={};
  int s=0,t;

  //一行の入力
  fgets(stack,MAX,stdin);
  //printf("%s\n",stack);
  len_stack = strlen(stack);
  //printf("%d\n",len_stack);

  for(i=0;i<len_stack;i++) {
    if(stack[i] >=48 && stack[i] <= 57 && stack[i+1] == ' ') {
      number[j] = atoi(&stack[i]);
      j++;
    } else
     if(stack[i] >=48 && stack[i] <= 57 && stack[i+1] != ' ') {
       //printf("check\n");
      number[j] = atoi(&stack[i]);
      num = number[j];
      //桁数が２桁以上の場合、それを一つに格納したあと、次の空\\
白まで飛ぶ
      while(num!=0) {
        num = num / 10;
        len_number++; //桁数
      }
      i+=len_number;
      j++;
    }
    //桁数を０に戻す
    len_number=0;

    //printf("%d ",i);

    t=j;//見ている箱
    //printf("%d;%d\n",i,t);
    switch(stack[i]) {
    case 43: //"+"
      //printf("%d;%d\n",i,t);
        number[t-2] += number[t-1];
        number[t-1] = 0;
        //number[t] = 0;
      j-=1;
      break;
    case 45: //"-"
      //printf("%d;%d\n",i,t);
        number[t-2] -= number[t-1];
        number[t-1] = 0;
        //number[t] = 0;
      j-=1;
      break;
    case 42: //"*"
      //printf("%d;%d\n",i,t);
        number[t-2] *= number[t-1];
        number[t-1] = 0;
        //number[t] = 0;
      j-=1;
      break;
    case 47: //"/"
      //printf("%d;%d\n",i,t);
        number[t-2] /= number[t-1];
        number[t-1] = 0;
        //number[t] = 0;
      j-=1;
      break;
    }
  }


  printf("%d\n",number[0]);

  return 0;
}

