n,k=map(int,input().split()) s=[(i+1,j) for i,j in enumerate(input())] stack=[] if s[k-1][1]=='(': for i,j in s: if j=='(': stack.append(i) else: n=stack.pop() if n==k: print(i) exit() else: for i,j in s: if j=='(': stack.append(i) else: if i==k: print(stack[-1]) exit() stack.pop()