#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100
int main(){
int i=0,x[N],j=0;
char a[N];

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

    if ( a[i] == '+' ){
j--;
x[j-1]=x[j-1]+x[j];
    } else if ( a[i] == '-' ){
j--;
x[j-1]=x[j-1]-x[j];
    } else if ( a[i] == '*' ){
j--;
x[j-1]=*x[j]
    } else {
      x[j] = atoi(s);
j++;
    }
i++;
  }
printf("%d\n",x[0]);
  return 0;
}