#include #include #include using namespace std; int main() { int n, k; string s; cin >> n >> k >> s; int ans; stack paren_stack; for (int i = 0; i < s.length(); i++) { if (s[i] == '(') { paren_stack.push(i); } else { int pos = paren_stack.top(); paren_stack.pop(); if (s[k - 1] == '(') { if (pos == k - 1) { ans = i + 1; break; } } else { if (i == k - 1) { ans = pos + 1; break; } } } } cout << ans << endl; return 0; }