#include<stdio.h>
void push(int);
int pop(void);

int stack[100];
int top;
int main(){
  int top,stack[100];
  char c;
  top = 0;
  while(scanf("%c",&c) != EOF){
    if( '0' <= c && c <= '9' ){
      push((int)c);
    }
    if( c == '+' ){
      stack[top] += pop();
    }
    if( c == '-' ){
      stack[top] -= pop();
    }
    if( c == '*' ){
      stack[top] *= pop();
    }
  }
  printf("%d\n",stack[top]);

  return 0;
}
void push(int x){
  top++;
  stack[top] = x;
}
int pop(void){
  top--;
  printf("%d\n",stack[top]);
  return stack[top+1];
}