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

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

int top=0;
int stack[100];

int main(){
  int x,a,b;
  char s[100];

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      x = pop() + pop();
      push(x);
    } else if(s[0] == '-'){
      a = pop();
      b = pop();
      x = b - a;
      push(x);
    } else if(s[0] == '*'){
      x = pop() * pop();
      push(x);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[top]);

  return 0;
}

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

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

