#include <bits/stdc++.h>
using namespace std;
string s;
bool pd()
{
if (strchr(")+*/", s[0]) != nullptr)
return true;
for (int i = 0; i < s.size(); i++)
if (s[i] == '-' && (i == 0 || strchr("(+-*/", s[i - 1]) != nullptr))
s.insert(i, "0");
for (int i = 0; i < s.size() - 1; i++)
if (strchr("+-*/", s[i]) != nullptr && strchr("+-*/", s[i + 1]) != nullptr || s[i] + s[i + 1] == '(' + ')')
return true;
int k = 0;
for (int i = 0; i < s.size(); i++)
if (s[i] == '(')
k++;
else if (s[i] == ')')
{
if (k == 0)
return true;
else
k--;
}
if (k)
return true;
return false;
}
vector<string> zztohz()
{
stack<char> ops;
vector<string> hz;
string num = "";
string yxj = "+-*/"; // 0123 /2 0011
for (int i = 0; i < s.size(); i++)
{
if (s[i] >= '0' && s[i] <= '9')
{
num += s[i];
// isdigit(ch) 判断ch是否是数字
if (strchr("0123456789", s[i + 1]) == nullptr)
{
hz.push_back(num);
num = "";
}
}
else if (s[i] == '(')
ops.push(s[i]);
else if (s[i] == ')')
{
while (!ops.empty() && ops.top() != '(')
{
hz.push_back(string(1, ops.top()));
ops.pop();
}
ops.pop();
}
else if (strchr("+-*/", s[i]) != nullptr)
{
while (!ops.empty() && ops.top() != '(' && yxj.find(ops.top()) / 2 >= yxj.find(s[i]) / 2)
{
hz.push_back(string(1, ops.top()));
ops.pop();
}
ops.push(s[i]);
}
else
{
while (!ops.empty() && ops.top() != '(')
{
hz.push_back(string(1, ops.top()));
ops.pop();
}
}
}
return hz;
}
int js(int a, int b, char c)
{
switch (c)
{
case '+':
return a + b;
case '-':
return a - b;
case '*':
return a * b;
case '/':
return a / b;
}
return 0;
}
int main()
{
cin >> s;
if (pd())
cout << "NO";
else
{
vector<string> hz = zztohz();
stack<int> nums;
for (int i = 0; i < hz.size(); i++)
{
if (isdigit(hz[i][0]))
nums.push(stoi(hz[i]));
else
{
int b = nums.top();
nums.pop();
int a = nums.top();
nums.pop();
nums.push(js(a, b, hz[i][0]));
}
}
cout << nums.top();
}
return 0;
}