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