n, k = map(int, input().split()) s = input() x = 0 idx = {} idx[0] = 0 for i in range(n): if s[i] == '(': x += 1 idx[x] = i + 1 else: x -= 1 if i + 1 == k: print(idx[x] + 1) break if idx[x] + 1 == k: print(i + 1) break idx[x] = i + 1