#include #define rep(i, n) for(long long i = 0; i < n; i++) #define ALL(v) (v).begin(), (v).end() using namespace std; using lint = long long; int main() { int n, k; string s; cin >> n >> k >> s; k--; stack st; rep(i, n) { if (s[i] == '(') { st.emplace(i); } else { int tp = st.top(); st.pop(); if (tp == k || i == k) { cout << (tp == k ? i + 1 : tp + 1) << endl; return 0; } } } }