#define REP(i,n) for(int i=0; i<(int)(n); i++) #include #include inline int getInt(){ int s; scanf("%d", &s); return s; } #include #include using namespace std; int main(){ const int n = getInt(); const int k = getInt() - 1; string s; cin >> s; stack st; REP(i,n){ if(s[i] == '('){ st.push(i); }else{ const int p = st.top(); st.pop(); if(p == k || i == k){ printf("%d\n", p == k ? i + 1 : p + 1); } } } return 0; }