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