#include int main(){ int N,K; scanf("%d %d",&N,&K); char S[10000+1]; scanf("%s",S); int level = 0; int buffer[10000]; for (int i = 0;i < N;i++){ if (S[i] == '('){ level++; buffer[i] = level; }else{ buffer[i] = level; level--; } } if (S[K-1] == '('){ for (int i = K;i < N;i++){ if (buffer[i] == buffer[K-1]){ printf("%d\n",i+1); break; } } }else{ for (int i = K-2;i >= 0;i--){ if (buffer[i] == buffer[K-1]){ printf("%d\n",i+1); break; } } } }