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

#define MAX 100

void initialize(void);
void push(int);
int pop(void);
int isEmpty(int);
int isFull(int);

int top;
int S[1000];

int main(){

  int c = 0;
  int pop2;
  char s;

  initialize();

  while(scanf("%c",&s) != EOF ){
    if(s == ' '){
      if(c!=0)push(c);
      c = 0;
      continue;
    }
    
    if(s == '+'){
      push(pop() + pop());
      printf("%d\n",S[top]);
    }
    else if(s == '*'){
      push(pop() * pop());
    }
    else if(s == '-'){
      pop2 = pop(); //??????push?????????
      push(pop() - pop2);
    }
    else if(s == '\n'){
      printf("%d\n", pop());
      break;
    }
    else {
      c = c * 10 + atoi(&s);
    }
  }
  
  return 0;
}

void initialize(void){
  top = 0;    
}

void push(int x){
  if(isFull(top) == 1){
    printf("??¨?????????????????????????????????\n");
    exit(1);
  }
  S[++top] = x;
}

int pop(void){
  
  if(isEmpty(top) == 1){
    printf("??¨???????????¢?????????????????????\n");
    exit(2);
    return 0;
  }    
  
  top--;
  return S[top+1];
}

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

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