N,K=map(int,input().split()) S=list(input()) ANS={} queue=[] for i in range(N): if S[i]==')': idx=queue.pop() ANS[idx]=i+1 ANS[i+1]=idx else:# =='(' queue.append(i+1) print(ANS[K])