def main(): n, k = [int(x) for x in input().split(" ")] s = list(input()) l = [] for i in range(len(s)): if i > k and len(l) == k: ans = i break if s[i] == "(": l.append(s[i]) else: l.pop() print(ans) if __name__ == "__main__": main()