n, k = map(int, input().split()) s = input() st = [] dic1, dic2 = {}, {} for i in range(n): if i + 1 == k: t = s[i] if s[i] == "(": st.insert(0, i) else: j = st.pop(0) dic1[i] = j dic2[j] = i if t == "(": print(dic2[k - 1] + 1) else: print(dic1[k - 1] + 1)