#include <stdio.h>
#include <stdlib.h>
#define N 100
int push(char *);
void pop(int,int;);
int a,b;
int main(){
  char data;
  int S[N];
  int i=0,top=0;

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