#include #define ll long long #define ld long double #define rep(i,a,b) for (int i = a; i < b; i++) #define irep(i,a,b) for (int i = a; i > b; i--) #define print(n) cout << n << endl #define rup(a,b) (a+b-1)/b using namespace std; int main(){ cout << fixed << setprecision(15); int N,K; string s; cin >> N >> K >> s; K--; if (s[K]=='('){ int count = 0; rep(i,K,N){ if (s[i]=='(') count++; else{ count --; if (count == 0){ print(++i); return 0; } } } }else if(s[K]==')'){ int count = 0; irep(i,K,-1){ if (s[i]==')') count ++; else{ count --; if (count == 0){ print(++i); return 0; } } } } system("pause"); return 0; }