#include #include using namespace std; int main() { int N, K; while( cin >> N >> K ){ string S; cin >> S; int rank = 0; int memo = 0; for( int i = 0; i < N; ++i ){ int p; if( S[ K - 1 ] == '(' ){ p = i; if( p < K - 1 ) continue; }else{ p = N - i - 1; if( p > K - 1 ) continue; } if( p == K - 1 ){ memo = rank; } if( S[ p ] == '(' ) ++rank; if( S[ p ] == ')' ) --rank; if( memo == rank ){ cout << p + 1 << endl; break; } } } return 0; }