#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int stack[200],s_ptr=0;
void push(int d){
    stack[s_ptr]=d;
    s_ptr++;
}
int pop(void){
    s_ptr--;
    return stack[s_ptr];
}
int main(void){
    int a,b;char str[1200],*tok;
    fgets(str,1200,stdin);
    tok=strtok(str," ");
    while(tok!=NULL){
        if (tok[0] >= '0' && tok[0] <= '9'){push(atoi(tok));}
        else if (tok[0]=='-'){b=pop();a=pop();push(a-b);}
        else if (tok[0]=='+'){b=pop();a=pop();push(a+b);}
        else if (tok[0]=='*'){b=pop();a=pop();push(a*b);}
        tok=strtok(NULL," ");
    }
    printf("%d\n",pop());
}
    
