#include #include using namespace std; int main(){ int n,k;cin>>n>>k;k--; string s;cin >> s; vector arr; for(int i = 0; n > i; i++){ arr.push_back(i); while(true){ if(s[arr[arr.size()-2]] == '(' && s[arr[arr.size()-1]] == ')'){ if(arr[arr.size()-2] == k){ cout << arr[arr.size()-1]+1 << endl; break; }else if(arr[arr.size()-1] == k){ cout << arr[arr.size()-2]+1 << endl; break; } arr.pop_back();arr.pop_back(); }else{ break; } } } }