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

int main(){
    int i,j;
    char ope[100];
    int s[100];
    for(i=0;i<100;i++){
        s[i]=0;
    }
    i=0;

    while( scanf("%s", ope) != EOF ){
        if ( ope[0] == '+' ){
            s[i-2]=s[i-2]+s[i-1];
            i-=1;

        } else if ( ope[0] == '-' ){
            s[i-2]=s[i-2]-s[i-1];
            i-=1;

        } else if ( ope[0] == '*' ){
            s[i-2]=s[i-2]*s[i-1];
            i-=1;

        } else {
            s[i] = atoi(ope);
            i++;
        }

    }
    printf("%d\n",s[0]);
    return 0;
}

