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


int main(){
    int A[100],top=0,i;
    char s[100];
    while(scanf("%s",s) != EOF ){
        if( s[0] == '+' ){
            top--;
            A[top] = A[top] + A[top+1];
        }else if ( s[0] == '-' ){
            top--;
            A[top] = A[top] - A[top+1];
        }else if ( s[0] == '*' ){
            top--;
            A[top] = A[top] * A[top+1];
        }else {
            top++;
            A[top] = atoi(s);
            
}
    }
      printf("%d\n",A[1]);
    return 0;
}

