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

void push(int);
int pop();

int top;
int dat[10000];

int main() {
  int x,y;
  char data[100];

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

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

void push(int x) {
  dat[++top] = x;
}

int pop() {
  top--;
  return dat[top + 1];
}

  
    
    
      
      
  


