#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100

int A[N],top=0;
   
int main(){
  int a,b,c;
  char s[N];
     
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a = A[top-2];
      b = A[top-1];
      c = a + b;
      A[top] = c;
      top = top -2;
    }
    else if(s[0]=='-'){
      a = A[top-2];
      b = A[top-1];
      c = a - b;
      A[top] = c;
      top = top -2;
    }
    else if(s[0]=='*'){
      a = A[top-2];
      b = A[top-1];
      c = a * b;
      A[top] = c;
      top = top -2;
    }
    else{
      A[top] = atoi(s); 
      top = top + 1;
    }
  }
   
  printf("%d\n",A[top+2]);
    
  return 0;
}