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