n,k=map(int,input().split()) k-=1 s=input() stack=[] ans=[] for i in range(n): if stack: last,ind=stack[-1][0],stack[-1][1] if last=='(' and s[i]==')': stack.pop() ans.append((ind,i)) else: stack.append((s[i],i)) else: stack.append((s[i],i)) for x,y in ans: if x==k: print(y+1) break elif y==k: print(x+1) break