#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STACK_MAX 1000

void push(int);
int pop();
static int top;
static int stack[STACK_MAX];

int main()
{
  int num,ans1,ans2;
  char c[100];

  while((scanf("%s",c))!=EOF){
    if(c[0]=='+'){
      ans1=pop();
      ans2=pop();
      push(ans2+ans1);
    }else if(c[0]=='-'){
      ans1=pop();
      ans2=pop();
      push(ans2-ans1);
    }else if(c[0]=='*'){
      ans1=pop();
      ans2=pop();
      push(ans2*ans1);
    }else{
      num=atoi(c);
      push(num);
    }
  }

  printf("%d\n",pop());
  return 0;
}

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

