#include using namespace std; #define REP(i,a,b) for(i=a;i'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(int *x, int *y){reader(x);reader(y);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} int N, K; char S[11000]; int main(){ int i, j, k; reader(&N,&K); K--; reader(S); if(S[K]=='('){ k = 0; for(i=K;;i++){ if(S[i]=='(') k++; else k--; if(k==0) break; } } else { k = 0; for(i=K;;i--){ if(S[i]=='(') k++; else k--; if(k==0) break; } } writer(i+1,'\n'); return 0; }