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

void push(int a);
int pop(void);

int top;
int stack[200];


int main(void)
{
  int m,n;
  char data[100];

  while(scanf("%s",data) != -1){

    if(data[0] == '+'){
      m = pop();
      n = pop();
      push(m+n);
      
    } else if (data[0] == '-'){
      n = pop();
      m = pop();
      push(m-n);
      
    } else if(data[0] == '*'){
      m = pop();
      n = pop();
      push(m*n);
      
    } else {
      push(atoi(data));
    }
  }

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

  return 0;
}




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


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


