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

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

int top = 0;
int S[101];

int main(){
  int x;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop()+pop());
    } else if ( s[0] == '-' ){
      x = pop()-pop();
      push(x * -1);
    } else if ( s[0] == '*' ){
      push(pop()*pop());
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",S[1]);

  return 0;
}

void push(int x){
  if(top == 101)exit(1);
  top++;
  S[top] = x;
}

int pop(void){
  if(top == 0)exit(2);
  top--;
  return S[top+1];
}

