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

int top = 0, S[150];

void push(int x){
    top = top + 1;
    S[top] = x;
}

int pop(){
    top = top - 1;
    return S[top + 1];
}

int main( void ){
    int a, b, i, num, flag, n;
    top = 0;
    char s[500];
    fgets(s, 500, stdin);
    flag = 0;
    num = 0;
    for(i = 0; s[i] != '\n'; i++){
        if(s[i] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }
        else if(s[i] == '-'){
            a = pop();
            b = pop();
            push(b - a);
        }
        else if(s[i] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }
        else if(s[i] == ' '){
            if(flag >= 1){  //1個前が数字の場合
                for(n = 1; n <= flag; n++){
                    num += (s[i - n] - '0') * pow(10, n - 1);   //正しい10進数の数になおす
                }
                push(num);
                flag = 0;
                num = 0;
            }
        }
        else{
            flag += 1;
        }
        /*
        int j;
        for(j = 0; j < 10; j++){
            printf("%d ", S[j]);
        }
        printf("\ntop = %d\n", top);
        printf("s[%d] = %c\n\n",i,s[i]);*/    //11 2 + 13 4 - *
    }
    printf("%d\n", pop());
    return 0;
}

