#include <bits/stdc++.h>
using namespace std;
stack<int> st;
int main() {
        string s;
    while(cin>>s){
        if (isdigit(s[0])){
            st.push(stoi(s));
        }
        else{
            int a,b;
            a=st.top();
            st.pop();
            b=st.top();
            st.pop(); 
            if (s=="+"){
                st.push(a+b);
            }
            else{
                if (s=="*"){
                   st.push(a*b);
            }
                
                else{
                        if (s=="/"){
                    st.push(a/b);
                    }
                    else{
             
                   st.push(a-b);
            
            }
                
                }
                }
        }
    }
    cout<<st.top();
}
