//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a) memset(a, 0x00, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("out.txt","w",stdout)
#define pb push_back
#define pp pop_back
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout << "hi" << endl
typedef long long ll;

using namespace std;

int main()
{
    //iDEBUG;

    string str;
    getline(cin, str);
    vector<int> vec;

    for(int i=0; i<str.length(); i++)
    {
        if(str[i] == ' ')
            continue;
        if(str[i]>='0' && str[i]<='9')
            vec.pb(str[i]-'0');
        else
        {
            int a, b;
            b = vec.back(); vec.pp();
            a = vec.back(); vec.pp();
            switch(str[i])
            {
                case '+':
                    a += b;
                    break;
                case '-':
                    a -= b;
                    break;
                case '*':
                    a *= b;
                    break;
            }
            vec.pb(a);
        }
    }
    cout << vec.back() << endl;

    return 0;
}

