#include<stdio.h>

#define STACK_MAX 100

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

int stack[STACK_MAX];
int top=0;

main(){
  char S[200];
  scanf("%s",S);
  printf("%d",cal(S));

  return 0;
}


int cal(char S[]){
  int i,a,b;
  for(i=0;S[i] !='\0';i++){

    switch(S[i]){
    case '+':
      a = pop();
      b = pop();
      push(a+b);
      break;

    case '-':
      a = pop();
      b = pop();
      push(a-b);
      break;

    case '*':
      a=pop();
      b=pop();
      push(a*b);
      break;
      
    default :
      push(S[i]);
    break;
    }
  }
  return pop();
}

int isEmpty(){
  return top==0;
}

int isFull(){
  return top >= MAX -1;
}


int push(x){
  if (isFull()) break; 
  top++;
  S[top] = x;
}


int pop(){
  if (isEmpty()) break;
  top--;
  return S[top+1];
}