#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define SIDE 100

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

int stack[SIDE];
int top = 0;

void push(int x){
  stack[++top] =x;
}


int pop(){
  top--;
  return stack[top+1];
}

int main(){
  int a,b,sum;
  top=0;
  char s[1000000];

  while(scanf("%s",s) != EOF){
    if(s[0]=='+'){
      a = pop();
      b = pop();
      push(b + a);
    }
    else if(s[0]=='-'){
      a = pop();//a=4
      b = pop();//b=3
      push(b - a);   //1 
    }
    else if(s[0]=='*'){
      a = pop();
      b = pop();
      push(b * a);    
    }
    else{
      push(atoi(s));
    }
  }
  
  printf("%d\n",pop());
  return 0;
}

