#include <bits/stdc++.h>
#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

void solve() {
  int N, K;
  string s;
  cin >> N >> K >> s;

  vector<int> v(N);
  stack<int> st;

  rep(i, 0, N) {
    if (s[i] == '(') {
      st.push(i);
    } else {
      v[i] = st.top();
      v[st.top()] = i;
      st.pop();
    }
  }
  cout << v[K - 1] + 1 << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  getchar();
}