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

int sr[10000];
int top = 0;

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

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

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


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

  return 0;
}

int pop(){
  int a;
  a = sr[top];
  top--;
  return a;
}

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

