#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define True 1
#define False 0
#define MAX 1000

int top, S[MAX];

void push(int);
int pop(void);

int main()
{
  int a,b,ret;
  char s[100];
  
  top = 0;

  while(1){
    if(scanf("%s",s) == EOF)break;
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }else {
      push(atoi(s));
    }
  }

  printf("%d\n",pop());  

  return 0;
}

void push(int x){
  S[++top] = x;
}

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


