#include<iostream>
#include<cassert>
#include<string>
#include<cctype>
using namespace std;

const string S = "(1+((12+2)*3-5)/37)*2-4";
size_t cur = 0;
int parse();
int digit();
int number();
int expression();
int term();
int factor();

int main() {
	int a = parse();
	assert(cur == S.size());
	cout << a << endl;
	return 0;
}

int digit() {
	assert(isdigit(S[cur]));
	int n = S[cur] - '0';
	cur++;
	return n;
}

int number() {
	int n = digit();
	while (cur < S.size() && isdigit(S[cur]))
		n = n * 10 + digit();
	return n;
}

int expression() {
	int a = term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
		char op = S[cur++];
		int b = term();
		if (op == '+') a += b;
		else a -= b;
	}
	return a;

}

int parse() {
	return expression();
}

int term() {
	int a = factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
		char op = S[cur++];
		int b = factor();
		if (op == '*') a *= b;
		else a /= b;
	}
	return a;
}

int factor() {
	if (S[cur] != '(') return number();
	cur++;
	int n = expression();
	assert(S[cur] == ')');
	cur++;
	return n;

}