#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair Pr; int N, K; string s; int main() { cin >> N >> K >> s; char c = s[K - 1]; int c_num = 0,ans; if (c == '(') { for (int i = K; i < s.size(); i++) { if (c == s[i]) c_num++; else { if (c_num == 0) { ans = i + 1; break; } else c_num--; } } } else { for (int i = K - 2; i >= 0; i--) { if (c == s[i]) c_num++; else { if (c_num == 0) { ans = i + 1; break; } else c_num--; } } } cout << ans << endl; return 0; }