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

#define N 1000
#define n 100

int top, A[N];

void push(int x);

int pop();

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

  return 0;
}

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

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

