// Stack
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 200

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


int top, S[1000];

int main(){
  int i, n, a, b;
  char str[100];
  initialize();
  top = 0;

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

void initialize(){
  top = 0;
}

int isEmpty(){
  if(top == 0)return 1;
  else return 0;
}

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

void push(int x){
  //if(isFull() == 1) exit(8);
  top++;
  S[top] = x;
}

int pop(){
  //if(isEmpty() == 1) exit(8);
  //else {
    top--;
    return S[top + 1];
    //}
}

