#include #include #include using namespace std; int main() { int N, K, b; cin >> N >> K; string str; cin >> str; vector> a(N, vector(2)); for (int i = 0; i < N; i++) { if (str[i] == '(') { a[i][0] = 1; } else { a[i][0] = 2; } } while (true) { for (int i = 0; i < N; i++) { if (a[i][0] == 1 && !a[i][1]) { b = i; continue; } if (a[i][0] == 2 && !a[i][1]) { a[b][1] = a[i][1] = 1; if (b == K - 1) { cout << i + 1 << endl; return 0; } else if (i == K - 1) { cout << b + 1 << endl; return 0; } break; } } } }