#include #include #include #include #include #include #include using namespace std; int main() { int n, k, x = 0; string str; cin >> n >> k >> str; if (str[k - 1] == '(') { for (int i = k; i < n; i++) { if (str[i] == '(') x++; else if (x == 0) { cout << i + 1 << endl;; return 0; } else x--; } } else { for (int i = k - 1; i >= 0; i--) { if (str[i] == ')') x++; else x--; if (x == 0) { cout << i + 1 << endl; return 0; } } } return 0; }