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

int S[100000],top;

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

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


int main(){
  char stack[100000];
  int status,a,b;
  while(1){
    status = scanf("%s", stack);
    if( status == -1) break;
    if( stack[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if( stack[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if( stack[0] == '*'){
      a = pop();
      b = pop();
      push( a * b);
    }
    else
      push(atoi(stack));
  }

  printf("%d\n", pop());

  return 0;
}

      

