#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ull = unsigned long long; using ll = long long; int main() { int n,k; cin >> n >> k; string s; cin >> s; int count = 0; int result = 0; if(s.at(k-1) == '(') { for(int i = k-1; i < n; ++i) { if(s.at(i) == '(') ++count; else --count; if(count == 0) { result = i+1; } } } else { for(int i = k-1; i >= 0; --i) { if(s.at(i) == ')') ++count; else --count; if(count == 0) { result = i+1; } } } cout << result << endl; }