try: import mydebug def dprint(*objects, sep='', end='\n'): print(*objects) except: def dprint(*objects, sep='', end='\n'): pass n, k = [int(x) for x in input().split()] s = input().rstrip() stc = [] pairs = [] dprint(s) state = "" dprint("len(s)",len(s)) for i in range(len(s)): dprint("-----", i+1, s[i]) if s[i] == "(": dprint("append", i+1) stc.append(i+1) state += "(" dprint(state) else: state = state[:-1] dprint(state) dprint("pop", stc[-1]) pairs.append((i+1, stc[-1])) stc.pop() def other(t, n): if t[0] == n: return t[1] else: return t[0] for p in pairs: if k in p: dprint(p) print(other(p, k))