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


#define MAX 1000
void push(int);
int pop(void);

int Stack[MAX];
int top=0;

int main(){
  
  int a,b;
  top = 0;
  char stack[100];
  
  while(scanf("%s",stack)!=EOF){
    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;
}

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


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