#include using namespace std; int main() { while(true) { int N; cin >> N; if(cin.eof()){ return 0; } int oneCount = 0; // string newString = ""; char nextChar; char prevChar; for(int i = 0; i < N; i++){ cin >> nextChar; if(nextChar == '('){ oneCount++; } } cout << oneCount << endl; // cin >> prevChar; //// create new string - no need for online // for(int i = 1; i < N; i++){ //// newString += prevChar; // cin >> nextChar; // if(prevChar == '('){ // if(nextChar == ')'){ //// newString += "1"; // oneCount++; // } // } else { // if(nextChar == ')'){ //// newString += "+1"; // oneCount++; // } else { //// newString += "+"; // } // } // prevChar = nextChar; // } // cout << oneCount << endl; // newString += prevChar; // stack ops; // stack values; // unordered_map PRIORITY; // PRIORITY['('] = 1; // PRIORITY[')'] = 2; // PRIORITY['+'] = 3; // 10 ((())(())) // int oneCount = 0; // for(const auto &c: newString){ // if(c == '1'){ // oneCount++; // } // } // for(const auto &c : newString){ // if(c != '1'){ // while(c != '(' && !ops.empty() && PRIORITY[ops.top()] >= PRIORITY[c]){ // auto right = values.top(); // values.pop(); // auto left = values.top(); // values.pop(); // ops.pop(); // values.push(left + right); // } // if(c == ')'){ // ops.pop(); // } else { // ops.push(c); // } // } else { // values.push(1); // } // } // while(!ops.empty()){ // if(ops.top() == '(' || ops.top() == ')'){ // ops.pop(); // continue; // } // auto right = values.top(); // values.pop(); // auto left = values.top(); // values.pop(); // ops.pop(); // values.push(left + right); // } // cout << values.top() << endl; } return 0; }