#include<stdio.h>
#include<stdlib.h>
#define MAX 100
#define SIZE 100

int stack[SIZE];
int stack_size = 0;

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

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

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

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




