#include <stdio.h>
#include <stdlib.h>
#define MAX 101

void initialize();
int isEmpty();
int isFull();
void push(int);
int pop();

int S[MAX],top;

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

  initialize();

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

printf("%d\n", S[top]);
return 0;
}

void initialize(){
  top = 0;
}

int isEmpty(){
  return top == 0;
}

int isFull(){
  return top >= MAX - 1;
}

void push(x){
  if(isFull()){
    printf("WTF1\n");
    exit(1);
  }
  top++;
  S[top] = x;
}

int pop(){
  if (isEmpty()){
    printf("WTF2\n");
    exit(2);
  }
  top--;
  return S[top+1];
}