#include<stdio.h>
#include<ctype.h>
#define max 100
int stack[max];
int top=-1;
void push(int val){
    stack[++top]=val;
}
int pop(){
    return stack[top--];
}
int main(){
    char postfix[max];
    fgets(postfix,max,stdin);
    for(int i=0;postfix[i]!='\0';i++){
        if(isdigit(postfix[i])){
            push(postfix[i]-'0');
        }
        else if(postfix[i]=='+'||postfix[i]=='-'||postfix[i]=='*'||postfix[i]=='/'){
            int b=pop();
            int a=pop();
            switch(postfix[i]){
                case +: push(a+b); break;
                case -: push(a-b); break;
                case *: push(a*b); break;
                case /: push(a/b); break;
            }
        }
        
    }
    printf("%d",pop());
    return 0;
    
}