#include<stdio.h> 
#define STACK 100
#define MAX 100

int Digit(char *);
int get_num(char *);
int sum(char *);


int st[STACK];
int stack_size=0;
int main()
{
  char data[MAX];
  scanf("%s",data);
  printf("%d\n",sum(data));
  
  return 0;
}

int pop()
{
  if(stack_size<= 0)return 0;
  return st[--stack_size];
}

int push(int a)
{
  st[stack_size++]=a;
}

int Digit(char *data)
{
  if(*data=='+' || *data=='-' || *data=='*'){
    data++;
    
    if(*data>='0' && *data<='9')return 1;
    return 0;
    
  }
  
  else if(*data>='0' && *data<='9')return 1;
  return 0;
}

int get_num(char *data)
{
  
  int sign=0,n=0;
  
  if(*data=='+')data++;
  
  else if(*data=='-'){
    sign=1;
    data++;
  }
  while(*data>='0' && *data<='9'){
    n=n*10+(*data-'0');
    data++;
    
    if(sign)return -n;
    return n;
  }
}

int sum(char *data)
{
  int x,y,n;
  
  while(*data){
    
    if(Digit(data)){
      n=get_num(data);
      push(n);
      while(*data == '-' || *data == '+'){
	data++;
      }
      while(n){
	n/=10;
	data++;
      }
    }
    else{
      
      switch(*data){
	
      case '+':
	x=pop();
	y=pop();
	push(x+y);
	break;
	
      case '-':
	x=pop();
	y=pop();
	push(x-y);
	break;
	
      case '*':
	x=pop();
	y=pop();
	push(x*y);
	break;
      }
      data++;
    }
    
  } 
  return pop(); 
}

      
      