#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define OPED 100
#define OPER 99

void push(int);
int pop();

int top,S[OPER *2];

int main(){
  int a,b;
  int top = 0;
  char s[OPED];

  while(scanf("%s",s) != EOF){
    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] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;
}

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

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

