#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; typedef long long lint; #define MIN(a,b) ((a)<(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b)) int main() { int i, N, K, scope = 0, l; string S; cin >> N >> K >> S; for (i = 0; i < K; i++) S[i] == '(' ? scope++ : scope--; l = scope; for (; scope != l - 1; i++) S[i] == '(' ? scope++ : scope--; cout << i << endl; return 0; }