/*
* @Author: hungeazy
* @Date: 2023-11-22 19:26:24
* @Last Modified by: hungeazy
* @Last Modified time: 2024-10-03 10:21:16
*/
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define ull unsigned long long
#define sz(x) x.size()
#define sqr(x) (1LL * (x) * (x))
#define all(x) x.begin(), x.end()
#define fill(f,x) memset(f,x,sizeof(f))
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define FOD(i,r,l) for(int i=r;i>=l;i--)
#define ii pair<int,int>
#define iii pair<int,ii>
#define di pair<ii,ii>
#define vi vector<int>
#define vii vector<ii>
#define mii map<int,int>
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define __lcm(a,b) (1ll * ((a) / __gcd((a), (b))) * (b))
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i)
#define BIT(x,i) ((x) & MASK(i))
#define SET_ON(x,i) ((x) | MASK(i))
#define SET_OFF(x,i) ((x) & ~MASK(i))
#define oo 1e18
#define name "BIEUTHUC"
#define endl '\n'
#define time() cout << "-------------Time:" << 1000.0 * clock() / CLOCKS_PER_SEC << "ms.";
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
int tinh(int x, int y, char c)
{
if (c == '+') return x+y;
if (c == '-') return x-y;
if (c == 'x') return x*y;
if (c == ':' and y != 0) return x/y;
else return 0;
}
int level(char c)
{
if (c == '+' or c == '-') return 1;
if (c == 'x' or c == ':') return 2;
return 0;
}
int calc(string s)
{
int i = 0;
stack<int> a; stack<char> b;
FOR(i,0,s.size()-1)
{
if (s[i] == '(') b.push(s[i]);
else if (isdigit(s[i]))
{
int x = 0;
while (i < s.size() and isdigit(s[i])) x = x*10+(s[i]-'0'), i++;
a.push(x); i--;
}
else if (s[i] == ')')
{
while (!b.empty() and b.top() != '(')
{
int x = a.top(); a.pop();
int y = a.top(); a.pop();
char z = b.top(); b.pop();
a.push(tinh(y,x,z));
}
if (!b.empty()) b.pop();
}
else
{
while (!b.empty() and level(b.top()) >= level(s[i]))
{
int x = a.top(); a.pop();
int y = a.top(); a.pop();
char z = b.top(); b.pop();
a.push(tinh(y,x,z));
}
b.push(s[i]);
}
}
while (!b.empty())
{
int x = a.top(); a.pop();
int y = a.top(); a.pop();
char z = b.top(); b.pop();
// cout << x << " " << y << ' ' << z << endl;
a.push(tinh(y,x,z));
}
return (a.empty()?0:a.top());
}
signed main()
{
fast;
if (fopen(name".inp","r"))
{
freopen(name".inp","r",stdin);
freopen(name".out","w",stdout);
}
string s;
cin >> s;
if (s.size() == 0) cout << 0;
else cout << calc(s);
return 0;
}
// ██░ ██ █ ██ ███▄ █ ▄████
//▓██░ ██▒ ██ ▓██▒ ██ ▀█ █ ██▒ ▀█▒
//▒██▀▀██░▓██ ▒██░▓██ ▀█ ██▒▒██░▄▄▄░
//░▓█ ░██ ▓▓█ ░██░▓██▒ ▐▌██▒░▓█ ██▓
//░▓█▒░██▓▒▒█████▓ ▒██░ ▓██░░▒▓███▀▒
// ▒ ░░▒░▒░▒▓▒ ▒ ▒ ░ ▒░ ▒ ▒ ░▒ ▒
// ▒ ░▒░ ░░░▒░ ░ ░ ░ ░░ ░ ▒░ ░ ░
// ░ ░░ ░ ░░░ ░ ░ ░ ░ ░ ░ ░ ░
// ░ ░ ░ ░ ░ ░