r,t=[],[0]* n for i in range(n): if s[i]=='(':r.append(i) else: j=r.pop() t[i],t[j]=j,i print(t[k-1]+1)