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