#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define full  -1
#define empty -1
#define N 200

void popnum();
void push();
int pop();
int isempty();
int isfull();

int c[N];
int top=0,a,b;

int main(){
  int x,i;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      popnum();
      push(a+b);
    } else if ( s[0] == '-' ){
      popnum();
      push(a-b);
    } else if ( s[0] == '*' ){
      popnum();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());

  return 0;
}

void push(int x){
  if(isfull()!=full)
    c[top++]=x; 
}
int pop(){

  if(isempty()!=empty){
    return c[--top]; 
  }
  else return empty;

}
int isempty(){
  if(top==0)return empty;
  return 0;
}
int isfull(){
  if(top==N)
    return full;
  return 0;
}

void popnum(){
  b=pop();
  a=pop();
}

