#include <stdio.h>

int main(){
  int a[128] = {}, i = 0;
  char in;
  while(scanf("%c", &in) && in != '0'){
    switch(in){
    case '+':
      a[i - 2] += a[i - 1];
      i--;
      break;
    case '-':
      a[i - 2] -= a[i - 1];
      i--;
      break;
    case '*':
      a[i - 2] *= a[i - 1];
      i--;
      break;
    case ' ':
      break;
    default:
      a[i++] = in - '0';
      break;
    }
  }
  printf("%d\n", a[i - 1]);
  return 0;
}