/* -*- coding: utf-8 -*- * * 3144.cc: No.3144 Parentheses Modification and Rotation (01 Ver.) - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ /* global variables */ char s[MAX_N + 4]; /* subroutines */ /* main */ int main() { int n, r, m; scanf("%d%s%d%d", &n, s, &r, &m); if (n & 1) { puts("-1"); return 0; } int c0 = 0; for (int i = 0; i < n; i++) if (s[i] == '(') c0++; int c1 = n - c0; printf("%d\n", abs(c1 - c0) / 2); return 0; }