#include #include #include #include #include //--------------------------- using namespace std; //--------------------------- #define REP(i,n) for(int i = 0; i < (n); i++) #define P(x) cout << (x) << "\n" //--------------------------- int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); int n,k;cin >> n >> k; string s;cin >> s; vector> a; a.resize(n); REP(i,n){ a[i].resize(2); } //a[i][0]<初期数値、a[i][1]<括弧状態0,1 REP(i,n){ a[i][0] = i; if (s[i] == '(') { a[i][1] = -1; }else{ a[i][1] = 1; } } //削除 int sum = 0; if (a[k-1][1] == -1) { for (int i = k-1; i < n; i++) { if (a[i][1] == -1) { sum--; }else{ sum++; } if (sum == 0) { P(i+1); break; } } }else if (a[k-1][1] == 1) { for (int i = k-1; i >= 0; i--) { if (a[i][1] == -1) { sum--; }else{ sum++; } if (sum == 0) { P(i+1); break; } } } return 0; }