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

#define MAX 100

int main(){
int x,stack[MAX],i=0;
char a[MAX];

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

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

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

else{
x = atoi(a);
stack[i]=a;
i++;
}
}

printf("%d\n",stack[0]);

return 0;
}