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