N, K = map(int, (input().split())) S = input() c = 0 x = 0 if S[K-1] == "(": while not x == 1: c += 1 if S[K-1+c] == ")": x += 1 else: x -= 1 print(K+c) else: while not x == 1: c += 1 if S[K-1-c] == "(": x += 1 else: x -= 1 print(K-c)