#include #include #define rep(i,n) for(i=0;i<(int)(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; int n,k; int main(){ int i,j; scanf("%d%d",&n,&k); stack sta; k--; getchar(); rep(i,n){ if(getchar()=='(') sta.push(i); else{ j=sta.top(); if(j==k){ printf("%d\n",i+1); return 0; } if(i==k){ printf("%d\n",j+1); return 0; } sta.pop(); } } return 0; }