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