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

#define MAX 256

int array[MAX]; 
int depth = 0;

void push(int n) {
 array[depth++] = n;
}

int pop() {
 return array[--depth];
}

//stack function
void stack(char input, int num)
{
    num=-1;
    while (scanf("%c", &input) != EOF) {

 
  if ('0' <= input && input <= '9') {
   num = (num < 0 ? input - '0' : 10 * num + input - '0');
  }

  //push
  if (input == ' ') {
   if (num >= 0) push(num);
   num = -1;
  }

  if (input == '+') {
   push(pop() + pop());
  }

  if (input == '-') {
   int a = pop(), b = pop();
   push(b - a);
  }

  if (input == '*') {
   push(pop() * pop());
  }
 }

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

int main() {
    char input;
    int num;
    stack(input,num);

 return 0;
}
