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

void push(int);
int pop(void);

int S[101];
int j=0;

int main(void){
  char s[200];
  int x,m,n,i=0,count=0;
  
  while(1){
    scanf("%c",&s[i]);
    if(s[i] == '\n'){
      s[i]='\0';
      break;
    }    
    i++;
  }
  for(i = 0 ; i < strlen(s) ; i++){
    for(count=i ; s[count] != ' ' ; count++);
    
    if(s[i] >= '0' && '9' >= s[i]){
      x = atoi(s+i);
      i = count;
      push(x);
    }
    else if(s[i] == '+'){
      m = pop();
      n = pop(); 
      push(n+m);
      
    }
    else if(s[i] == '-'){
      m = pop();
      n = pop(); 
      push(n-m);
      
    }
    else if(s[i] == '*'){
      m = pop();
      n = pop(); 
      push(n*m);
      
    }
    
  }
  
  printf("%d\n",S[0]);
  return 0;
}

void push(int x)
{
  S[j++] = x; 
}

int pop(void)
{
  return S[--j];
}