#include <stdio.h>
#include <stdlib.h>
#define MAX 100

void push(char);
int pop();

int S[MAX];
int top=0;
int main(){
  int i=0,vb,vd,vc,x,y,t,result;
  char a[MAX];

  while(result!=EOF){
    result=scanf("%c",&a[i]);
    i++;
    if(a[i]=='+'||a[i]=='-'||a[i]=='*'){
      vc=atoi(&a[i-2]);
      vd=atoi(&a[i-1]);
      x= pop(vc);
      y= pop(vd);
      if(a[i]=='+'){
	t=x+y;
	push(t);
      }
      else if(a[i]=='-'){
	t=x-y;
	push(t);
      }
      else{
	t=x*y;
	push(t);
      }
    }
    else{
      vb=atoi(&a[i]);
      push(vb);
   
    }
  }
  printf("%d\n",S[0]);

  return 0;
}


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