def main(): N, K = map(int, input().split()) S = input() lst = [0] * (N + 1) stack = [] apnd = stack.append pop_ = stack.pop i = 1 for j, s in enumerate(S): if s == '(': apnd(i) lst[j+1] = i i += 1 else: lst[j+1] = pop_() indexes = [i for i, x in enumerate(lst) if x == lst[K]] x = indexes[0] ^ indexes[1] ^ K print(x) main()