#include using namespace std; int main() { int N, K; string S; cin >> N >> K >> S; K--; vector V(N); set SE; for (int i = 0, id = 0; i < N; i++) { if (S.at(i) == '(') V.at(i) = id++; else { int tmp = id - 1; while (SE.count(tmp)) tmp--; V.at(i) = tmp; SE.insert(tmp); } } int tmp = V.at(K); for (int i = 0; i < N; i++) { if (i == K) continue; if (V.at(i) == tmp) return cout << i + 1 << "\n", 0; } }