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

int top,S[1000000];

void push(int a){
  S[++top] = a;
}

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

  
}

int main(){
  
  int x, y, z;
  top = 0;
  char array[100];
  
  while(1)
    {
    if( scanf("%s", &array[0]) == EOF ) break;
    
    if ( array[0] == '+' ){
      x = pop();
      y = pop();
      push(x + y);
    } 
    else if ( array[0] == '-' ){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if ( array[0] == '*' ){
      x = pop();
      y = pop();
      push(x * y);
    }
    else {
      z = atoi(array);
      push(z);
    }
    }
  
  printf("%d\n", pop());
  
  return 0;
}