#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { // Input int N, K; cin >> N >> K; string S; cin >> S; // Simulation And Output --K; deque> p; rep(i, S.size()) { if (S[i] == '(') { p.push_back({S[i], i}); } else { int j = p.back().second; p.pop_back(); if (i == K) cout << j + 1 << endl; if (j == K) cout << i + 1 << endl; } } }