#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(){
  int x,a[101],count=1;
  char str[100];
 
  while(scanf("%s",str) != EOF){
    if(s[0]=='+'){
      a[count-2] += a[count-1];  
      count--;
    }

    else if(s[0]=='-'){
      a[count-2]-=a[count-1];
      count--;
    }

    else if( s[0] == '*' ){
      a[count-2] *= a[count-1]; 
      count--;
    }

    else{
      x=atoi(s);
      a[count]=x;
      count++;
    }
  }
  printf("%d\n",a[b-1]);
  return 0;
}