n,k=map(int,raw_input().split()) s=raw_input() t=[] u=[] for i in range(n): if s[i]=="(": t.append(i) else: j=t.pop() if i+1==k: print j+1 exit() elif j+1==k: print i+1 exit()