n, k = map(int, input().split()) k = k - 1 ss = list(input()) left_start = True if ss[k] == "(" else False ss_slice = [] if left_start: ss_slice = ss[k:] else: ss_slice = list(reversed(ss[:k+1])) left, right = 0, 0 for i, s in enumerate(ss_slice): if s == "(": left += 1 else: right +=1 if left == right: if left_start: print(k + i + 1) else: print(k - i + 1) break