#include<stdio.h>
#include<stdlib.h>
static int top, S[1000];

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

int pop(){
  return S[top--];
}

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