N, K = [int(i) for i in input().strip().split(" ")] S = input() stack = [] for idx,s in enumerate(S): if s == "(": stack.append([idx]) else: tmp = stack.pop() tmp.append(idx) if K == (idx+1): print("%d"%(tmp[0]+1)) break elif K == (tmp[0]+1): print("%d"%(idx+1)) break