#include #include #include using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int n, k; string S; cin >> n >> k >> S; vector T(n); int i = 0, j = 0; bool flg = false; while (!flg) { while (S[i] != ')' || T[i] != 0) { i++; } T[i] = ++j; flg = i == n - 1 ? true : false; while (T[i] > 0) { i--; } T[i] = j; } int m; char mark; rep(i, n) { if (i + 1 == k) { m = T[i]; mark = S[i]; } } rep(i, n) { if (T[i] == m && S[i] != mark) { cout << i + 1 << endl; } } }