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

int S[100];
int top;

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

void init(){
  top = 0;
}

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

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

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

  return 0;
}