#include #include using namespace std; using LL = long long; int main() { int N, K; string S; cin >> N >> K >> S; stack stk1; stack stk2; int ans; for (int i = 1; i <= N; i++) { if (S[i - 1] == '(') { stk1.push(S[i - 1]); stk2.push(i); } else { if (stk2.top() == K) { ans = i; break; } else if (i == K) { ans = stk2.top(); break; } else { stk1.pop(); stk2.pop(); } } } cout << ans << endl; }