n, k = map(int, input().split()) s = list(input()) def f(k): count = 0 if s[k-1] == ')': while True: if s[k-1] == ')': count += 1 else: count -= 1 if count == 0: return k k -= 1 elif s[k-1] == '(': while True: if s[k-1] == '(': count += 1 else: count -= 1 if count == 0: return k k += 1 print(f(k))