#include<stdio.h>
#include<stdlib.h>
#define N 199
#define MAX 100

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

int S[MAX];
int top;

int main()
{
  char Y[MAX];
  int i=0,a,b;

  while(1){
    if(scanf(" %s",&Y) == EOF) break;
    
    if(Y[0] >= '0' && Y[0] <='9') push(atoi(Y));
    
    if(Y[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(Y[0] == '-'){
      a = pop();
      b = pop();
      push(b - a);
    }
    else if(Y[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
  }
  
  printf("%d\n",pop());     
  
  return 0;
}

void initialize()
{
  top = 0;
}

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

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

int pop()
{
  int *x;
  if(isEmpty() == 1){
  top--;
  return S[top+1];
  }
}