#include #include #include using namespace std; int main() { int N, cookies = 0; string S; cin >> N >> S; for(int i = 1; i < N; i++) { if ((S[i] == ')' && S[i - 1] == '(') || (S[i] == ')' && S[i - 1] == ')')) cookies += 1; } cout << cookies; return 0; }