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

void push(int);
void pop(void);
void change_number(char);

int stac[1000];
int top=0;

int main(){
  char c;
  int num1, num2;

  while(1){

    scanf("%c",&c);
    if(c == '\n') break;
    
    if(c == '+'){
      num1 = stac[top-1];
      num2 = stac[top];
	    
      pop();
      pop();
     
      push(num1+num2);
    }
    else if(c == '-'){
      num1 = stac[top-1];
      num2 = stac[top];

      pop();
      pop();

      push(num1-num2); 
    }
    else if(c == '*'){
      num1 = stac[top-1];
      num2 = stac[top];

      pop();
      pop();

      push(num1*num2);
    }
    else if('1'<= c && c<='9'){
      change_number(c);
    }
  }

  printf("%d\n",stac[top]);
  return 0;
}

void push(int x){
  stac[top+1] = x;
  top++;
}

void pop(void){
  top--;
}

void change_number(char x){
  char array[100];
  int i=0, n;
  char c;
  
  array[i] = x;
  while(1){
    scanf("%c",&c);
    if(c == ' '){
      array[i+1] = '\n';
      n = atoi(array);
      push(n);
      break;
    }
    else{
      i++;
      array[i] = c;
    }
  }
}