#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define FOE(i,a) for(auto i : a) #define ALL(c) (c).begin(), (c).end() #define EXIST(v, n) (std::find(v.begin(), v.end(), 1) != v.end()) using namespace std; int main(int argc, char *argv[]) { int N, K; string S; cin >> N >> K; cin >> S; map ans; stack> stack; REP(i, N) { if (S[i] == '(') { stack.push({ i, S[i] }); } else if (S[i] == ')') { int f = stack.top().first; stack.pop(); ans[f+1] = i+1; ans[i+1] = f+1; } } cout << ans[K] << endl; }