n, k = map(int, input().split()) s = str(input()) d = [] for i in range(n): if s[i] == '(': d.append(i+1) else: if d[-1] == k: print(i+1) exit() elif i+1 == k: print(d[-1]) exit() else: d.pop()