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

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

int S[1000],top;

int main(){
  int x,i,j;
  char s[100];
  top = 0;

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