def main(): N, K = map(int, input().split()) S = input() lst = [0] * N i = 0 for j in range(N): if S[j] == '(': i += 1 lst[j] = i else: lst[j] = i i -= 1 i = lst[K-1] indexes = [j for j, x in enumerate(lst) if x == i] if indexes[0] == K - 1: print(indexes[1] + 1) else: print(indexes[0] + 1) main()