n,k = map(int,input().split()) s = input() st = [] for i,si in enumerate(s): i += 1 if st and st[-1][0] == "(" and si == ")": if i == k: ans = st[-1][1] break elif st[-1][1] == k: ans = i break else: st.pop() else: st.append((si,i)) print(ans)