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