#include using namespace std; using ll = long long; using Graph = vector>; int main () { int N,M; cin >> N >> M; string S; cin >> S; stack sta; stack dic; M--; if(S[M] == '(') { int ans = 0; for(int i = 0; i < N; i++) { if('(' == S[i]) { sta.push(S[i]); dic.push(i); }else { sta.pop(); int x= dic.top(); dic.pop(); if(x == M) { ans = i + 1; } } } cout << ans << endl; }else { int ans = 0; for(int i = N - 1; i >= 0; i--) { if(')' == S[i]) { sta.push(S[i]); dic.push(i); }else { sta.pop(); int x= dic.top(); dic.pop(); if(x == M) { ans = i + 1; } } } cout << ans << endl; } }