#include using namespace std; int main () { int N, K; char s[10000+1]; cin >> N >> K >> s; int n = K; if (s[K] == '(') { int cnt = 1; for (int i = K; i < N; i++) { if (s[i] == '(') cnt++; else cnt--; if (cnt == 0) { cout << i+1 << endl; break; } } } else { int cnt = -1; for (int i = K; i > 1; i--) { if (s[i] == ')') cnt--; else cnt++; if (cnt == 0) { cout << i+1 << endl; break; } } } return 0; }