N, K = map(int, input().split(' ')) cnt = 0 t = [0 for i in range(N)] for i, s in enumerate(input()): if s == '(': cnt += 1 t[i] = cnt if s == ')': cnt -= 1 tmp = t[K-1] t[K-1] = 0 print(t.index(tmp) + 1)