n, k = map(int, input().split(" ")) k -= 1 b = input() s = [i for i in range(n)] while True: i = b.index("()") p = [s.pop(i), s.pop(i)] b = b.replace("()", "", 1) if k in p: print(sum(p) - k + 1) break