#include #include using namespace std; int main(void) { int N = 0, K = 0; string S; pair p; cin >> N >> K >> S; while(true){ for(int i = 0; i < N; i++){ if(S[i] == '('){ p.first = i; for(int j = i + 1; j < N; j++){ if(S[j] == ')'){ p.second = j; S[p.first] = S[p.second] = ' '; break; } else if(S[j] == '('){ p.second = -1; break; } } if(p.second != -1){ if(p.first+1 == K){ cout << p.second+1 << endl; return 0; } if(p.second+1 == K){ cout << p.first+1 << endl; return 0; } } } } } return 0; }