#include using namespace std; #define all(p) p.begin(), p.end() #define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++) int main(){ int N; cin >> N; string S; cin >> S; int R, M; cin >> R >> M; if (N % 2){ cout << "-1\n"; } else{ int tmp = 0; for (auto c : S) tmp += (c == '(' ? -1 : 1); cout << abs(tmp) / 2 << "\n"; } }