#include using namespace std; int to_int(string s) { int res = 0; for (int i = 0; i < (int)s.size(); i++) { res = res * 10 + (s[i] - '0'); } return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; stack st; for (int i = 0; i < N; i++) { string s; cin >> s; if (s == "+") { int a = st.top(); st.pop(); int b = st.top(); st.pop(); st.push(a + b); } else if (s == "-") { int a = st.top(); st.pop(); int b = st.top(); st.pop(); st.push(b - a); } else { st.push(to_int(s)); } } cout << st.top() << '\n'; return 0; }