#include #include #include #include #include #include #include #include #include #include #include #include #include #define p(s) cout<<(s)<=n;i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define F first #define S second typedef long long ll; using namespace std; const int inf = 1e9+7; int N, K; int idx[10010]; string s; int ans; int main() { cin>>N>>K>>s; REP(i, 0, s.size()){ if(s[i]=='('){ idx[i+1]=idx[i]+1; }else{ idx[i+1]=idx[i]-1; } } if(s[K-1]=='('){ REP(i,K+1,N){ if(s[i-1]=='(') continue; if(idx[K] == idx[i]+1){ ans=i; break; } } }else{ RREP(i,1,K){ if(s[i-1]==')') continue; if(idx[K] == idx[i]-1){ ans=i; break; } } } p(ans); return 0; }