#include<bits/stdc++.h>
using namespace std;
int evaluatepostfix( string exp)
{
    stack<int>  st;
    for(char c: exp)
    {
        if(c==' ')
        {
            continue;
        }
        else if(c>='0' && c<='9')
        {
            st.push(c -'0');
        }
        else
        {
            int val2 = st.top();
            st.pop();
            int val1 =st.top();
            st.pop();
            switch(c)
            {
                case'+':
                st.push(val1 + val2);
                break;
                
                case'-':
                st.push(val1 - val2);
                break;
                
                case'*':
                st.push(val1-val2);
                break;
                
                case'/':
                st.push(val1/val2);
                break;
            }
            
        }
      
    }
     return st.top();
    
}
int main ()
{
     int string exp;
     getline(cin, exp);
     cout<<evaluatepostfix(string exp);
     return 0;
}