#include<stdio.h>
#include<stdlib.h>
#define N 100


void push(int);
int pop(void);
int top=0,in[N];

int main(){

  char ch[N];
  int i,anum,bnum;

  i=0;

  while(scanf("%s",ch)!=EOF){
    if(ch[i]=='+'){
      anum=pop();
      bnum=pop();
      push(anum + bnum);
    }else if(ch[i]=='-'){
      anum=pop();
      bnum=pop();
      push(bnum - anum);
    }else if(ch[i]=='*'){
      anum=pop();
      bnum=pop();
      push(anum * bnum);
    }else{
      push(atoi(ch));
    }
    
  }

  printf("%d\n",pop());

  return 0;
}

void push(int a){
  top++;
  in[top]=a;
}

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

