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

#define MAX 1000

int top,S[MAX];

int pop(void);
void push(int);

int main(){
  int a,b;
  char s[MAX];

  top = 0;

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      a = pop();
      b = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else push(atoi(s));
  }

  printf("%d\n",pop());
  return 0;
}

int pop(){

  top--;
  return S[top+1];
}

void push(int c){

  S[++top] = c;
}