#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000

void initialize();
int isEmpty();
int isFull();
void push(int);
int pop();
int top;
int S[100];

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

void initialize() {
  top = 0;
    }
int isEmpty() {
  if(top == 0) return 0;
  else return 1;
     }
int isFull() {
   if(top >= MAX - 1)  return 1;
   else return 0;
     }
void push(int x) {
  if(isFull() ==  1) {
   printf("??¨?????????????????????????????????\n");
  }
  top++;
     S[top] = x;
	      }
int pop() {
  if(isEmpty() == 0) {
    printf("??¨???????????¢?????????????????????\n");
  }
  top--;
     return S[top+1];
   }