#include using namespace std; typedef unsigned long long ul; typedef signed long long ll; ul over = 1000000007; int main(void) { cin.tie(0); ios::sync_with_stdio(false); cout << fixed; ll n, k; string s; cin >> n >> k >> s; k--; ll depth[n]; depth[0] = 1; for (int i = 1; i < n; ++i) { if (s[i] != s[i-1]) depth[i] = depth[i-1]; else if (s[i] == '(') depth[i] = depth[i-1]+1; else depth[i] = depth[i-1]-1; } if (s[k]=='(') { for (ll i = k+1; i < n; ++i) { if (depth[i]==depth[k]) {cout << i+1 << endl; return 0;} } } else { for (ll i = k-1; i >= 0; --i) { if (depth[i]==depth[k]) {cout << i+1 << endl; return 0;} } } return 0; }