#include<iostream>
#include<stdio.h>
#include<cstring>
#include <stdlib.h>
using namespace std;
//int * a = new int[1000001]
/*char *s = new char[1000000000];// = {}; //stack
char *post = new char[1000000000];// = {}; //postfix
int postlen = 0, slen = 0;
int *n = new int[200000000];*/
char s[100000000] = {};// = {}; //stack
char post[100000000] = {};// = {}; //postfix
int postlen = 0, slen = 0;
int n[10000000] = {};
int nlen = 0;
int putin(char a) {
if (a == '(') return 20;
if (a == ')') return 19;
if (a == '*') return 15;
if (a == '/') return 15;
if (a == '+') return 12;
if (a == '-') return 12;
if (a == '%') return 12;
}
void f(int i) {
//cout << i <<endl;
//cout << int(post[i-1]) << endl << endl;
//cout << n[nlen - 2] << " " << n[nlen - 1] << post[i] <<endl;
if (post[i] == '+') n[nlen - 2] = n[nlen - 2] + n[nlen - 1];
else if (post[i] == '-') n[nlen - 2] = n[nlen - 2] - n[nlen - 1];
else if (post[i] == '*') n[nlen - 2] = n[nlen - 2] * n[nlen - 1];
else if (post[i] == '/') n[nlen - 2] = n[nlen - 2] / n[nlen - 1];
else if (post[i] == '%') n[nlen - 2] = n[nlen - 2] % n[nlen - 1];
/*else if (post[i] == '-') post[i-2] = post[i-2] - post[i-1];
else if (post[i] == '*') post[i-2] = post[i-2] * post[i-1];
else if (post[i] == '/') post[i-2] = post[i-2] / post[i-1];
else if (post[i] == '%') post[i-2] = post[i-2] % post[i-1];*/
//cout << int(post[i-2]) << endl;
/*for (int j = i - 1 ; j < postlen-2 ; j++) {
post[j] = post[j+2];
}*/
//cout << post[i-1] << endl;
//postlen -= 2;
nlen--;
/*for (int i = 0 ; i < nlen ; i++) {
cout << n[nlen] << " ";
}
cout <<endl;*/
}
int num(int i) {
n[nlen] = 0;
while (post[i] != '.') {
n[nlen] *= 10;
n[nlen] += post[i] - 48;
i++;
}
//cout << n[nlen] << " " << i <<endl;
nlen++;
//i++;
return i;
}
//ins = putin % 20;
//(a/(b-c+d)*(e-a))*c
int main() {
char a[100000];
while (scanf("%[^\n]",&a) != EOF) {
/*s[1000] = {}; //stack
post[10000] = {}; //postfix
postlen = 0, slen = 0;
n[1000] = {}, nlen = 0;*/
memset(post, 0, sizeof(post));
memset(s, 0, sizeof(s));
memset(n, 0, sizeof(n));
postlen = slen = nlen = 0;
if (a[strlen(a) - 1] >= '0' && a[strlen(a) - 1 <= 9]) a[strlen(a)] = '.';
for (int i = 0 ; i <= strlen(a) ; i++) {
if (a[i] == ' ' && a[i-1] >= '0' && a[i-1] <= '9') a[i] = '.';
if (a[i] == ' ') continue;
if (a[i] >= '0' && a[i] <= '9' || a[i] == '.') {
post[postlen] = a[i];
postlen++;
} else {
if (a[i] != ')' && (slen == 0 || putin(a[i]) > putin(s[slen-1]) % 20)) {
s[slen] = a[i];
slen++;
//cout << a[i] << " 123" << endl;
//cout << s[slen-1] << endl;
} else {
if (a[i] == ')') {
//for (int j = 0 ; j < slen ; j++) cout << s[j] << " ";
//cout <<endl;
for (int j = slen-1 ; s[j] != '(' ; j--) {
post[postlen] = s[j];
postlen++;
//s[j] = '';
slen--;
}
slen--;
//for (int j = 0 ; j < slen ; j++) cout << s[j];
//cout <<endl;
//cout << slen <<endl;
} else {
//cout << a[i] << endl;
post[postlen] = s[slen-1];
postlen++;
s[slen-1] = a[i];
while (slen > 1 && putin(a[i]) <= putin(s[slen-2]) % 20) {
//cout << s[slen - 2] << "123456" << endl;
//cout << putin(s[slen - 2]) % 20 << "123456" << endl;
post[postlen] = s[slen-2];
postlen++;
slen--;
s[slen-1] = a[i];
//cout << s[slen-2] << endl;
//cout << post[postlen-1] << " " << a[i] << endl;
}
}
}
}
}
//cout << slen << endl;
for (int j = slen - 1 ; j >= 0 ; j--) {
post[postlen] = s[j];
postlen++;
}
//for (int j = 0 ; j < postlen ; j++) cout << post[j];
//cout <<endl;
for (int i = 0 ; i < postlen ; i++) {
if (!(post[i] >= '0' && post[i] <= '9')) {
f(i);
//i-=2;
} else {
i = num(i);
//cout << "123" << endl;
}
}
cout << n[0] << endl;
//n[0] = 0;
//cout << int(post[0]) << endl;
}
}