#include #define PI 3.14159265359 using namespace std; const int64_t MOD = 1e9 + 7; int N, K; int searchA(string S) { int cnt = 0; vector v; for (int i = 0; i < N; i++) { char ch = S.at(i); if ((ch == '(') || (ch == '{')) { v.push_back(ch); } else { if (v.at(v.size() - 1) == '{') { return i + 1; } else { v.pop_back(); } } } return -1; } int searchB(string S) { int cnt = 0; vector v; for (int i = S.size()-1; i >=0; i--) { char ch = S.at(i); if ((ch == ')') || (ch == '}')) { v.push_back(ch); } else { if (v.at(v.size() - 1) == '}') { return N - i; } else { v.pop_back(); } } } return -1; } int main() { string S; cin >> N >> K >> S; vector v; for (int i = 0; i < S.size(); i++) { char &ch = S.at(i); if (i == K - 1) { if (ch == '(') { ch = '{'; cout << searchA(S) << endl; } else { ch = '}'; cout << searchB(S) << endl; } } } }