#include <stdio.h>
#include <stdlib.h>
#define SIZE 100
#define true 1
#define false -1

int stack[SIZE];
int top = 0;

void push (int);
int pop (void);

int main() {

  char data[5];
  int temp,plus,minus,multi,temp1,temp2;
  
  while(1) {
    if(scanf("%s",data)== EOF) break;
    
    if(data[0] == '+') {
      temp1 = pop();
      temp2 = pop();
      plus = temp1 + temp2;
      push(plus);
    }
   
    else if(data[0] == '-') {
      temp1 = pop();
      temp2 = pop();
      minus = temp2 - temp1;
      push(minus);
    }
    
    else if(data[0] == '*') {
      temp1 = pop();
      temp2 = pop();
      multi = temp1 * temp2;
      push(multi);
    }
    
    else {
      temp = atoi(data);
      push(temp);
    }
  }
  printf("%d\n",stack[0]);
  return 0;
}
      

void push(int input)
{
  stack[top] = input;
  top++;
}

int pop(void)
{
  top--;
  return stack[top];
}

