n, k = map(int, input().split()) s = list(input()) l = k-1 p = 1 if s[k-1] == "(" else -1 c = 0 while l >= 0: if s[l] == '(': c += p else: c -= p if c <= 0: break l += p print(l + 1)