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

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

int main(){
  int opera[100],c=0;
  //int calc[2];
  char in[100];
  //long int ans = 0;
  int ans;

  while(scanf("%s",in)!=EOF){
    if(in[0]=='+'){
      opera[c-1] = opera[c-1] + opera[c];
      c = c - 1;
      //opera[c] = calc[0] + calc[1];
      //printf("+to%d,%d,%d\n",opera[0],opera[1],opera[2]);
    }
    else if(in[0]=='-'){
      opera[c-1] = opera[c-1] - opera[c];
      //calc[0]=opera[c-1];
      //calc[1]=opera[c];
      c = c - 1;
      //opera[c] = calc[0] - calc[1];
    }
    else if(in[0]=='*'){
      opera[c-1] = opera[c-1] * opera[c];
      //calc[0]=opera[c-1];
      //calc[1]=opera[c];
      c = c - 1;
      //opera[c] = calc[0] * calc[1];
    }
    else{
      c++;
      opera[c]=atoi(in);
      //printf("%d,%d,%d\n",opera[0],opera[1],opera[2]);
    }
    memset(in,'\n',100);
  }
  printf("%d\n",opera[1]);
  
  return 0;
}


