#include <stdio.h>
#include <stdlib.h>
int main(void){
    char c[10000];
    int a[2000];
    int i=0,j=0;
    while(scanf("%s",c) != EOF){
        switch(c[0]){
        case '%':
        a[i-2]=a[i-1]/a[i-2];
        i--;
        break;
        case '*':
        a[i-2]=a[i-1]*a[i-2];
        i--;
        break;
        case '+':
        a[i-2]=a[i-1]+a[i-2];
        i--;
        break;
        case '-':
        a[i-2]=a[i-1]-a[i-2];
        i--;
        break;
        default:
        a[i]=atoi(c);
        i++;
        break;
}
    }
    printf("%d\n",a[i-1]);
    return 0;
}