#include<stdio.h>
#include<stdlib.h>
int top,s[1000];
void op(int n){
    s[++top] = n;
}
int pop(void){
    top--;
    return s[top+1];
}
int main(){
    char s[100];
    top = 0;
    int a,b,i;
    i=0;
  while(scanf("%s",s)!=EOF){
    if(s[i]=='+'){
        a = pop();
        b = pop();
        op(a+b);
    }
    else if(s[0]=='-'){
        b = pop();
        a = pop();
        op(a-b);
    }
    else if(s[0]=='*'){
        a = pop();
        b = pop();
        op(a*b);
    }
    else {
        op(atoi(s));
    }
    }
  
    printf("%d\n",pop());
    return 0;
}




