#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; i >= 0; i--) { if (str[i] == ')') x++; else if (x == 0) { cout << i + 1 << endl; return 0; } else x--; } } return 0; }