#include #include #include using namespace std; typedef pair PCI; int main(void){ int n,k; vector stk; char c; cin >> n >> k; for (int i=1; i<=n; i++){ cin >> c; if (c=='(') stk.push_back(make_pair(c,i)); else { // c==')' PCI pci = stk.back(); if (i==k) cout << pci.second << endl; if (pci.second==k) cout << i << endl; stk.pop_back(); } } return 0; }