#include<stdio.h>

int i=0;

int atoi(char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

void push(int f[],int x){
  f[++i] = x; 
}

int pop(int f[]){
  return f[i--];
}

int main(){

  char c,s[10];
  int f[101],x,y,e=1;
  int j=0,k,check=0;

  while(scanf("%c",&c)){
    if(c==' '){
      if(check){
	x=0;
	for(k=j-1;k>=0;k--){
	  x += atoi(s[k])*e;
	  e *= 10;
	}
	push(f,x);
	check = 0;
	j = 0;
	e = 1;
      }
      continue;
    }
    else if(c == '\n') break;
    else if('0' <= c && c <= '9'){
      s[j] = c;
      j++;
      check = 1;
    }
    else{
      x = pop(f);
      y = pop(f);
      
      if(c == '+'){
	x += y;
      }
      else if(c == '-'){
	x = y - x;
      }
      else if(c == '*'){
	x *= y;
      }
      push(f,x);
     
    }
  }

  printf("%d\n",f[i]);
  
  return 0;
}


