#include char S[10001]; main(){ int N,K; scanf("%d %d %s",&N,&K,S); int count = 0;//(:+1 ):-1 if(K < N/2){ //前半の場合 for(int i = K-1;i < N;i++){ count += S[i]=='('?1:-1; if(count == 0){ printf("%d\n",i+1); return 0; } } }else{ for(int i = K-1;i >= 0;i--){ count += S[i]=='('?1:-1; if(count == 0){ printf("%d\n",i+1); return 0; } } } }