n,k=map(int,input().split()) l=list(input()) from collections import deque s=deque() ans=[] for i in range(n): if l[i]=="(": s.append(i) else: ans.append([i+1,s.pop()+1]) for x in ans: if x[0]==k: print(x[1]) exit() elif x[1]==k: print(x[0]) exit()