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

void push(int);
int pop(void);
int stack[100];
int stacksum=0;

int main(void)
{
  int i,x,y,data1;
  char data[100];
  scanf("%s",data);
  for(i=0;data[i] != EOF; i++){
    switch(data[i]){
    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;
    default:
      data1 = atoi("data[i]");
      push(data1);
      break;
    }
  }
  printf("%d\n",stack[1]);
  return 0;
}
void push(int data){
  stack[stacksum]=data;
  stacksum++;
}

int pop(void){
  
  stacksum--;
  return stack[stacksum];
} 