#include #define rep(i,n) for(int i=0;i<(n);++i) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair P; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int N, K; cin >> N >> K; string S; cin >> S; stack

st; vector

par; par.clear(); rep (i, N){ if (S[i] == '('){ st.push(P(i,-1)); }else{ P curr = st.top(); st.pop(); curr.second = i; par.push_back(curr); } // end if } // end rep int res = 0; rep (i, par.size()){ if (K - 1 == par[i].first){ res = par[i].second + 1; break; } // end if if (K - 1 == par[i].second){ res = par[i].first + 1; break; } // end if } // end rep cout << res << endl; return 0; }