//#define _GLIBCXX_DEBUG #include using namespace std; // 基本テンプレート #pragma region MACRO #define P(x) cout << (x) << endl #define p(x) cout << (x) #define PED cout << "\n" #define rep(i,n) for(int i=0; i<(int)n; ++i) #define REP(i,x,n) for(int i=x; i<(int)n; ++i) #define repi(i,n) for(int i=0; i<=(int)n; ++i) #define REPI(i,x,n) for(int i=x; i<=(int)n; ++i) #define ILP while(true) #define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i) #define ALL(c) (c).begin(), (c).end() #define mp make_pair #pragma endregion // 型 #pragma region TYPE_DEF typedef long long ll; typedef pair pii; typedef pair pss; typedef pair psi; typedef pair pis; typedef vector vi; typedef vector vd; typedef vector vl; typedef vector vll; typedef vector vs; #pragma endregion // Effective std #pragma region ESTD template int count(C& c, T t) { return count(ALL(c), t); } template int count_if(C& c, F f) { return count_if(ALL(c), f); } template void erase(C& c, T t) { remove(ALL(c), t), c.end(); } template void remove(vector& c, unsigned int index) { c.erase(c.begin()+index); } template void replace(C& c, T t, U u) { replace(ALL(c), t, u); } template void replace_if(C& c, F f, U u) { (ALL(c), f, u); } template void reverse(C& c) { reverse(ALL(c)); } template void sort(C& c) { sort(ALL(c)); } template void sort(C& c, Pred p) { sort(ALL(c), p); } #pragma endregion // 定数 #pragma region CONST_VAL constexpr int PI = (2*acos(0.0)); constexpr int EPS = (1e-9); constexpr int MOD = (int)(1e9+7); constexpr int INF = 100000000; #pragma endregion int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); int n, k; cin >> n >> k; string s; cin >> s; int cnt = 0; if (s[k - 1] == '(') REP(i, k, n) { if (s[i] == '(') ++cnt; else if ((s[i] == ')') and (cnt != 0)) --cnt; else { P(i + 1); break; } } else { for (int i = k - 2; i >= 0; --i) { if (s[i] == ')') ++cnt; else if ((s[i] == '(') and (cnt != 0)) --cnt; else { P(i + 1); break; } } } return 0; }