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

int top, A[1000];

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

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

int main(){
  int b, c;
  top = 0;
  char a[100];

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