def main(): N, K = map(int, input().split()) S = input() if S[K-1] == ")": next_index = (K-1)-1 count = 0 while count != 1: if S[next_index] == "(": count += 1 else: count -= 1 next_index = next_index - 1 # カウンタがすでに進んでいるので1を足し、 # 0始まりから1始まりに直すために更に1を足す print(next_index + 2) else: next_index = (K-1)+1 count = 0 while count != 1: if S[next_index] == ")": count += 1 else: count -= 1 next_index = next_index + 1 print(next_index) if __name__ == '__main__': main()