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

int stack[100];
int i= 1;

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

int main(){
  int buf1,buf2,ans;
  int x;
  char s[100];
  
  while( scanf("%s", s) != EOF){
    if ( s[0] == '+' ){
      buf1 = pop();
      buf2 = pop();
      ans = buf1 + buf2;
      push(ans);
    } 
    else if ( s[0] == '-' ){
      buf1 = pop();
      buf2 = pop();
      ans = buf2 - buf1;
      push(ans);
    } 
    else if ( s[0] == '*' ){
      buf1 = pop();
      buf2 = pop();
      ans = buf1 * buf2;
      push(ans);
    } 
    else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[i]);
  return 0;
}

int push(int x){
  i++;
  stack[i] = x;
}
int pop(void){
  i--;
  return stack[i+1];
}