#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100
void initialize(void);
int Empty(int);
int isFull(int);
void push(int, int*);
int pop(void);
int top=0, S[100];

int main(){
  int x;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      S[top-1] += pop();
    } else if ( s[0] == '-' ){
      S[top-1] -= pop();
    } else if ( s[0] == '*' ){
      S[top-1] *= pop();
    } else {
      x = atoi(s);
      push(x,S);
    }
  }
  printf("%d\n", S[top]);

  return 0;
}

void push(int x, int *S){
  top++;
  S[top] = x;
}
  
void initialize(void){
  int top = 0;
}

int isEmpty(int top){
  return top == 0;
}

int isFull(int top){
  return top >= MAX - 1;
}

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