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

void push(int);
int pop();

int s[10];
int top=0;

int main(){
  char A[10];
  int c,b;

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

void push(int x){
  top ++;
  s[top]=x;
}
int pop(){
  top--;
  return s[top+1];
}

