def main() -> None: n, k = map(int, input().split()) s = input() v = 0 p = 0 t = 1 if s[k-1] == "(": v = 1 p = k-1 else: v = -1 p = k p += v while True: # print(s,s[k-1],s[p], v, p, t) if s[p] != s[k-1] and t == 0: print(p) return None elif s[p] != s[k-1]: t -= 1 p += v else: t += 1 p += v if __name__ == "__main__": main()