#include<bits/stdc++.h>
#define int long long
using namespace std;
int solve(string s) {
    stack<int> st;
    int num = 0;
    char ops = '+';
    for(int i = 0; i < s.size(); i ++) {
        char c = s[i];
        if (isdigit(c)) num = num * 10 + (c - '0');
        if ((!isdigit(c) and c != ' ') or i == s.size() - 1){
            if (ops == '+') st.push(num);
            else if (ops == '-') st.push(-num);
            else if (ops == '*') {
                int top = st.top();
                st.pop();
                st.push(top * num);
            }
            else if (ops == '/') {
                int top = st.top();
                st.pop();
                st.push(top / num);
            }
            ops = c;
            num = 0;
        }
    }
    int ans = 0;
    while (!st.empty()) {
        ans += st.top();
        st.pop();
    }
    return ans;
}

signed main() {
    string s;
    getline(cin, s);
    cout << solve(s);
    return 0;
}