#include<stdio.h>

int top=0;
int stack[1000];

void push(int n){
  stack[++top]=n;
}

int pop(void){
  top--;
  return stack[top+1];
}

void calc(char op){
  int n1=pop(), n2=pop();
  if(op=='+') push(n1+n2);
  if(op=='-') push(n2-n1);
  if(op=='*') push(n2-n1);
}

int main(void){
  char a[1000];
  int t,s;
    while(scanf("%s",a)!=EOF){
      if(a[0]=='+' || a[0]=='-' || a[0]=='*') calc(a[0]);
      else push(atoi(a));
    }
  printf("%d\n",pop());
  return 0;
}