n, k = map(int, input().split()) s = list(input()) x = 1 l = [] for i in range(n): if s[i] == '(': l.append(x) x += 1 elif s[i] == ')': x -= 1 l.append(x) y = l[k-1] if k >= n//2: print(l.index(y) + 1) else: print(n - l[::-1].index(k))