#include #include #include #include #include #include #include #include int main(void) { //test用 //std::ifstream in("test.txt"); //std::cin.rdbuf(in.rdbuf()); int N, K; std::cin >> N >> K; std::string S; std::cin >> S; std::vector pair(N); while (S.find(")") <= N) { std::size_t temp1,temp2; temp1 = S.find(")"); temp2 = S.rfind("(", temp1); pair[temp1] = temp2; pair[temp2] = temp1; S[temp1] = '0'; S[temp2] = '0'; } std::cout << pair[K-1] + 1 << std::endl; }