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

int top = 0;
int S[100];

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

int main(){
  int x,j = 0,a,b,c,i = 0;
  char s[100];

while( scanf("%s", s) != EOF ){

    if(s[0] != ' '){

    if ( s[0] == '+' ){
        a = pop();
	b = pop();
 
	c = b+a;
	push(c);

    } else if ( s[0] == '-' ){
       a = pop();
	b = pop();
 
	c = b-a;
	push(c);

    } else if ( s[0] == '*' ){
        a = pop();
	b = pop();
 
	c = b*a;
	push(c);

    } else {
 
      x = atoi(s);
      push(x);

  
    }

    }

  }
  printf("%d\n",S[1]);

  return 0;
}

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

}

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