N, K = map(int, input().split()) K -= 1 S = input() stack = [] for i, s in enumerate(S): if s == '(': stack.append(i) else: l = stack.pop() if i == K: print(l + 1) break elif l == K: print(i + 1) break