#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int N, K; string S; cin >> N >> K; cin >> S; int pos = K - 1, level = 1, dir; char pare, other; if(S[pos] == '('){ dir = 1; pare = '('; other = ')'; } else{ dir = -1; pare = ')'; other = '('; } while(pos != 0 && pos != K){ pos += dir; //cout << pos << " " << level << endl; if(S[pos] == pare){ level++; } else{ level--; } if(level == 0) break; } cout << pos + 1 << endl; return 0; }