#include int main(void) { int count=0, number=0, kazu = 0; char kakko[10000]; int i; scanf("%d %d\n", &count, &number); //printf("%d %d",count,number); for (i = 0; i < count; i++) { scanf("%c", &kakko[i]); } //printf("%c",kakko[i]); for (i = number-1; i < 100000; i++) { if(i == count){ i = -1; }else { if(kakko[i] == '('){ kazu++; }else{ kazu--; } if(kazu == 0){ printf("%d",i+1); break; } } } return 0; }