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

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

int top, S[MAX];

void initialize(){
  top = 0;
}

void push(x){

  if(isFull() == 1 ){
    fprintf(stderr,"エラー（オーバーフロー）\n");
    exit(8);
  }

  else {

    S[++top] = x;
  }
}

int pop(){
  if(isEmpty() == 0 ){
    fprintf(stderr,"エラー（アンダーフロー）\n");
    exit(8);
  }
  top--;
  return S[top+1];
}

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

int isFull(){
  if( top >= MAX-1 ) return 1;
  else return 0;
}
int main(){
  int x,y;
  top = 0;
  char s[100];

  while( scanf("%s",s) != EOF ){
    if(s[0] == '+'){
      x = pop();
      y = pop();
      push( x+y );
    }
    else if(s[0] == '-'){
      y = pop();
      x = pop();
      push( x-y );
    }
    else if(s[0] == '*'){
      x = pop();
      y = pop();
      push(x*y);
    }
    else push(atoi(s));
  }
  printf("%d\n",pop());

  return 0;
}

