#include #include #include #include #include #define REP(i,n) for (int i=0;i<(n);i++) using namespace std; struct kakko{ string c; int n; }; int main(){ stack kakko2; int N, K; string tmp; cin >> N >> K; cin >> tmp; REP(i, N){ kakko ktmp; ktmp.n = i + 1; ktmp.c = tmp.substr(0, 1); tmp.erase(0, 1); if (ktmp.c == ")"){ if (ktmp.n == K){ kakko ktmp2 = kakko2.top(); cout << ktmp2.n << endl; } else{ kakko ktmp2 = kakko2.top(); if (ktmp2.n == K) cout << ktmp.n << endl; } kakko2.pop(); } else{ kakko2.push(ktmp); } } return 0; }