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