#include using namespace std; int main() { char line[200]; int n; cin >> n; cin >> line; long long val[200]; long long next[200]; int valPos = 0; int pos = 0; for ( ; ;) { if (pos == n) { break; } if (line[pos] == '(' && line[pos + 1] == ')') { val[valPos] = 1; valPos++; pos += 2; continue; } if (line[pos] == '(') { val[valPos] = -1; } if (line[pos] == ')') { val[valPos] = 0; } valPos++; pos++; } for ( ; ;) { if (valPos == 1) { break; } int nextPos = 0; int currentPos = 0; for ( ; ;) { if (currentPos >= valPos) { break; } if (val[currentPos] <= 0) { next[nextPos] = val[currentPos]; nextPos++; currentPos++; continue; } long long tmp = 1; while (currentPos < valPos && val[currentPos] > 0) { tmp *= val[currentPos]; currentPos++; } next[nextPos] = tmp; nextPos++; } memcpy(val, next, nextPos * sizeof(long long)); valPos = nextPos; nextPos = 0; currentPos = 0; for ( ; ;) { if (currentPos == valPos) { break; } if (currentPos > 0 && currentPos < valPos && val[currentPos] > 0 && val[currentPos - 1] == -1 && val[currentPos + 1] == 0) { nextPos--; next[nextPos] = val[currentPos] + 1; currentPos += 2; nextPos++; continue; } next[nextPos] = val[currentPos]; nextPos++; currentPos++; } memcpy(val, next, nextPos * sizeof(long long)); valPos = nextPos; } cout << val[0] << endl; return 0; }