#include<stdio.h>
#include<string.h>
void push(char);
void initialize();
int top;
int S[100];


int main(){
  int i = 0,j;
  char a[100],num;

  initialize();
   
  scanf("%[^\n]*s",a);

  j =  strlen(a);

  for(i = 0;i < j;i++){

    if(a[i] == ' ')continue;

    if(a[i] == '+' || a[i] == '-' || a[i] == '*'){
      if(a[i] == '+'){S[top-1] = S[top-1] + S[top];S[top]= 0;top--;}
      if(a[i] == '-'){S[top-1] = S[top-1] - S[top];S[top]= 0;top--;}
      if(a[i] == '*'){S[top-1] = S[top-1] * S[top];S[top]= 0;top--;}
    }

    else push(a[i]);
  }

  printf("%d\n",S[top]);

  return 0;
}

void push(char x){
  top++;
  S[top] = x - 48;
}

void initialize(){
  top = 0;
}