#include<stdio.h>
#define SUCCESS 0
#define FAILURE -1
#define STACK_SIZE 100
int stack[STACK_SIZE]={0};
int stack_num;

int push(int push_data){
    if (stack_num < STACK_SIZE){
        stack[stack_num]=push_data;
        stack_num++;
        return SUCCESS;
    }
    return FAILURE;
}

int pop(int *pop_data){
    if (stack_num > 0){
        *pop_data=stack[stack_num-1];
        stack_num--;
        return SUCCESS;
    }
    return FAILURE;
}

int main(void){
    char a[2000]={'\0'};
    int data1,data2;
    fgets(a, sizeof(a), stdin);
    stack_num=0;
    for (int i = 0; i < strlen(a); i++) {
        data1=0; data2=0;
        if ('0' <= a[i] && a[i] <= '9') {
            if (i>0 && '0' <= a[i-1] && a[i-1] <= '9') pop(&data1);
            push(data1*10+a[i]-'0'); continue;
        }
        if (a[i]=='+') {pop(&data2); pop(&data1); push(data1 + data2); continue;}
        if (a[i]=='-') {pop(&data2); pop(&data1); push(data1 - data2); continue;}
        if (a[i]=='*') {pop(&data2); pop(&data1); push(data1 * data2); continue;}
        if (a[i]=='/') {pop(&data2); pop(&data1); push(data1 / data2); continue;}
    }
    printf("%d\n",stack[stack_num-1]);
    return 0;
}
