n,m = map(int,input().split()) s = input() A = [] for i,t in enumerate(s): if '(' == t: A.append(i+1) else:# ')' == t: r = A.pop()+1 if r == m: print(i) if i == m: print(r)