def main(): N, K = map(int, input().split()) S = input() stack = [] for idx, bracket in enumerate(S, 1): match bracket: case "(": stack.append(idx) case ")": another = stack.pop() if idx == K: print(another) if another == K: print(idx) if __name__ == "__main__": main()