n, k = map(int, input().split()) s = list(input()) l = [1] d = 1 for i in range(1, len(s)): if s[i-1] == '(' and s[i] == '(': d += 1 l.append(d) elif s[i-1] == ')' and s[i] == ')': d -= 1 l.append(d) else: l.append(d) x = l[k-1] y = [i+1 for i, j in enumerate(l) if j == x] print(y[-1])