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