n=input()
s=raw_input()
a=[]
maxx=0
for i in s:
    a.append(i)
    if i=='(':
        maxx+=1
    else:
        maxx-=1
if maxx!=0:
    print 0
    print 1,1
else:
    x=1
    y=1
    maxx=0
    dp=[0]*n
    val=0
    for i in range(n):
        if a[i]=='(':
            val+=1
        else:
            val-=1
        dp[i]=val
    minn=min(dp)
    for i in dp:
        if i==minn:
            maxx+=1
    for i in range(n):
        for j in range(i,n):
            if(a[i]==a[j]):
                continue
            a[i],a[j]=a[j],a[i]
            dp=[0]*n
            val=0
            for i1 in range(n):
                if a[i1]=='(':
                    val+=1
                else:
                    val-=1
                dp[i1]=val
            minn=min(dp)
            for i1 in dp:
                if i1==minn:
                    val+=1
            if val>maxx:
                maxx=val
                x=i+1
                y=j+1
            a[i],a[j]=a[j],a[i]
    print maxx
    print x,y

N = int(input())
string = list(input())

def even(string):
    a = 0
    b = 0
    for c in string:
        if c == ")": a += 1
        if c == "(": b += 1
    return a == b
def swap(arr, i, j):
    arr[i], arr[j] = arr[j], arr[i]

def calc(string):
    N = len(string)
    l = 0
    s = 0
    for char in string:
        if char == "(":
            s += 1
        else:
            s -= 1
        l = min(l, s)

    if s != 0: return 0

    t = 0

    for i in range(N):
        c = string[i]
        if c == "(":
            s += 1
            if s - l <= 1:
                t += 1
        else:
            s -= 1
    return t

if even(string):
    highest = calc(string)
    a = b = 0
    for i in range(N):
        for j in range(i + 1, N):
            if string[i] == string[j]: continue
            swap(string, i, j)
            total = calc(string)
            if total > highest:
                highest = total
                a, b = i, j
            swap(string, i, j)

    print(highest)
    print(a+1, b+1)
else:
    print(0)
    print(1, 1)

import sys
input = sys.stdin.readline
def matcher(correcti):
    open_=0
    close_=0
    count=0
    excess=0
    for i in range(len(correcti)):
        if correcti[i]=='(':
            open_+=1
        if correcti[i]==')':
            close_+=1
        if close_>open_ and open_==0:
            excess+=1
            close_-=1
            count=0
            continue
        if open_==close_:
            count+=1
            open_=0
            close_=0
    if open_-close_==excess:
        if excess>0:
            return(count+1)
        else:
            return(count)
    else:
        return(0)
n=int(input())
l=[i for i in input() if i!='\n']
st=("".join(l).rstrip(')').rstrip('('))
swap=matcher(l[len(st):]+l[:len(st)])
#print(swap)
shifts=[[1,1]]
for i in range(n):
    for j in range(i,n):
        if l[i]!=l[j]:
            l[i],l[j]=l[j],l[i]
            output=(matcher(l))
            if output>swap:
                swap=output
                shifts[0]=[i+1,j+1]
            l[i],l[j]=l[j],l[i]
print(swap)
print(*shifts[0])

n = int(input())
seq = list(input())

def get_comps(seq):
    depth = 0
    components = 0
    lookingfor = 0
    for i in range(n):
        if seq[i] == "(":
            depth += 1
        else:
            depth -= 1
            if depth < lookingfor:
                lookingfor = depth
                components = 1
            elif depth == lookingfor:
                components += 1

    return components

def other(x):
    if x == "(":
        return ")"
    return "("

if n%2 == 1 or seq.count("(") != seq.count(")"):
    print(0)
    print(1,1)
else:
    best1 = 1
    best2 = 1
    bestVal = get_comps(seq)
    for i in range(n):
        for j in range(i+1,n):
            if seq[i] != seq[j]:
                seq[i] = other(seq[i])
                seq[j] = other(seq[j])
                val = get_comps(seq)
                if val > bestVal:
                    best1 = i
                    best2 = j
                    bestVal = val
                seq[i] = other(seq[i])
                seq[j] = other(seq[j])
    print(bestVal)
    print(best1+1,best2+1)

import math as mt
import collections as cc
import sys
#input=sys.stdin.readline
I=lambda:set(map(int,input().split()))
n,=I()
s=list(input())
tf=0
l=1
r=1
for i in range(n):
	for j in range(i+1,n):
		ans=0
		s[i],s[j]=s[j],s[i]
		ch=0
		cnt=0
		cm=0
		for k in s:
			if k=='(':
				ch+=1
			else:
				ch-=1
			if ch<cm:
				cm=ch
				cnt=1
			elif ch==cm:
				cnt+=1
		if ch==0 and cnt>tf:

			tf=cnt
			l=i+1
			r=j+1
		s[i],s[j]=s[j],s[i]
print(tf)
print(l,r)

def beauty(tt):
    depth = 0
    min_depth = 0
    dd = []
    for i, t in enumerate(tt):
        if t == '(':
            depth += 1
        else:
            depth -= 1
        dd.append(depth)
        if depth < min_depth:
            min_depth = depth
    if depth != 0:
        return(0)
    result = 0
    for d in dd:
        if d == min_depth:
            result+=1
    return(result)

def main():
    n = int(input())
    if n%2 == 1:
        print(0)
        print(1,1)
        return
    tt = input()
    best = beauty(tt)
    l = 1
    r = 1
    for i in range(n-1):
        for j in range(i+1, n):
            if tt[i] != tt[j]:
                ttt = list(tt)
                ttt[i] = tt[j]
                ttt[j] = tt[i]
                b = beauty(ttt)
                if b > best:
                    best = b
                    l = i+1
                    r = j+1
    print(best)
    print(l, r)

if __name__ == "__main__":
    main()

n = int(input())
s = list(input())
L = 1
R = 1
def check():
	calc = 0
	min = 0
	cntmin = 0
	for ch in s:
		if ch == '(':	calc += 1
		else:	calc -= 1
		if min > calc:
			min = calc
			cntmin = 1
		elif min == calc:
			cntmin += 1
	return cntmin if calc == 0 else 0

best = check()
for i in range(n):
	for j in range(i + 1, n, 1):
		s[i], s[j] = s[j], s[i]
		new = check()
		s[j], s[i] = s[i], s[j]
		if (new > best):
			best = new; L = 1+i; R = 1+j
print(best)
print(L, R)

n = int(input())
s = input()
res = 0
ri, rj = 0, 0
for i in range(n):
    for j in range(i + 1, n):
        #print(i, j)
        ss = s[:i] + s[j] + s[(i + 1): j] + s[i] + s[(j + 1):]
        #print(ss)
        k_mn, mn = 0, 0
        teck = 0
        for g in range(n):
            if ss[g] == '(':
                teck += 1
            else:
                teck -= 1
            if k_mn == 0 or teck < mn:
                mn, k_mn = teck, 1
            elif teck == mn:
                k_mn += 1

        if teck == 0:
            if k_mn > res:
                res = max(res, k_mn)
                ri = i
                rj = j
        #print(k_mn)
print(res)
print(ri + 1, rj + 1)

# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N =  INT()
S = list(input())

C = Counter(S)
if C['('] != C[')']:
    print(0)
    print(1, 1)
    exit()

def check(S):
    cur = cnt = mn = 0
    for s in S:
        if s == '(':
            cur += 1
        else:
            cur -= 1
        if cur < mn:
            mn = cur
            cnt = 1
        elif cur == mn:
            cnt += 1
    return cnt

mx = 0
ans = (1, 1)
for i in range(N):
    for j in range(i+1, N):
        S[i], S[j] = S[j], S[i]
        cnt = check(S)
        if cnt > mx:
            mx = cnt
            ans = (i+1, j+1)
        S[i], S[j] = S[j], S[i]
print(mx)
print(*ans)

"""
NTC here
"""
from sys import stdin, setrecursionlimit
setrecursionlimit(10**7)

def iin(): return int(stdin.readline())

def lin(): return list(map(int, stdin.readline().split()))

# range = xrange
# input = raw_input

def bcheck(a,l,r):
    a1=a[:]
    a1[l],a1[r]=a1[r],a1[l]
    N=len(a)
    p,n=[],[]
    for i in range(N):
        if a1[i]==')':
            if p:
                p.pop()
            else:
                n.append(i)
        else:
            p.append(i)
    l=len(p)
    rt=0
    if l>0:
        rt=n[-1]+1
    if rt:
        a1=a1[rt:]+a1[:rt]
    ch,pt=0,0
    for i in a1:
        if i=='(':
            pt+=1
        else:
            pt-=1
        if pt==0:ch+=1
    #print(a1,ch)

    return ch

def main():
    N=iin()
    a=list(input())
    c1,c2=a.count(')'),a.count('(')
    if c1!=c2 or N%2:
        print(0)
        print(1,1)
    else:
        mx=[-1,0,0]
     #   print(a)
        for i in range(N):
            for j in range(i+1,N):
                if a[i]!=a[j]:
                    val=bcheck(a,i,j)
                    if mx[0]<val:
                        mx=[val,i,j]
      #  print(a)
        a1=a[:]
        N=len(a)
        p,n=[],[]
        for i in range(N):
            if a1[i]==')':
                if p:
                    p.pop()
                else:
                    n.append(i)
            else:
                p.append(i)
        l=len(p)
        rt=0
        if l>0:
            rt=n[-1]+1
        if rt:
            a1=a1[rt:]+a1[:rt]
        ch,pt=0,0
        for i in a1:
            if i=='(':
                pt+=1
            else:
                pt-=1
            if pt==0:ch+=1
        if ch>mx[0]:
            print(ch)
            print(1,1)
        else:
            print(mx[0])
            print(mx[1]+1,mx[2]+1)

main()
# try:
#     main()
# except Exception as e: print(e)

n = int(input())
s = [1 if c == '(' else -1 for c in input()]
if s.count(1) != s.count(-1):
    print(0)
    print(1, 1)
    exit()

ans = 0
pair = 1, 1
for i in range(n-1):
    for j in range(i, n):
        s[i], s[j] = s[j], s[i]
        min_p, cnt = 10**9, 0
        nest = 0
        for k in range(n):
            nest += s[k]
            if min_p > nest:
                min_p = nest
                cnt = 1
            elif min_p == nest:
                cnt += 1

        if ans < cnt:
            ans = cnt
            pair = i+1, j+1

        s[i], s[j] = s[j], s[i]

print(ans)
print(*pair)

#!/usr/bin/env python3
import sys

#lines = stdin.readlines()
def rint():
    return map(int, sys.stdin.readline().split())

def input():
    return sys.stdin.readline().rstrip('\n')

def oint():
    return int(input())

n = oint()
stemp  = input()
s = []
for i in range(n):
    if stemp[i] == '(':
        s.append(1)
    else:
        s.append(-1)

maxcnt = 0
candi = [0, 0]
for l in range(n):
    for r in range(l, n):
        cnt = 0
        s[l], s[r] = s[r], s[l]
        ssum = [0]*n
        ssum[0] = s[0]
        for i in range(1, n):
            ssum[i] = ssum[i-1] + s[i]

        minssum = min(ssum)
        if ssum[n-1] != 0:
            continue

        for i in range(0, n):
            if ssum[i] == minssum:
                cnt += 1
        if maxcnt < cnt:
            candi = [r, l]
            maxcnt = cnt
        s[l], s[r] = s[r], s[l]
print(maxcnt)
print(candi[0]+1, candi[1]+1)

def do(i):
    if i == "(":
        return 1
    else:
        return -1
def find(i,idx):
    if i<n-idx:
        return idx+i+1
    else:
        return i-(n-idx)+1
n = input()
arr = map(do,raw_input())
s = [0]*n
s[n-1] = arr[n-1]
maxi = n-1
maxv = s[n-1]

for i in range(n-1)[::-1]:
    s[i] = s[i+1] + arr[i]
    if s[i] > maxv:
        maxv = s[i]
        maxi = i
newv = arr[maxi:]+arr[:maxi]
if sum(newv) != 0:
    print 0
    print 1,1
else:
    cnt = 0
    cnt1 = -1
    cnt2 = -1
    maxv1,maxv2 = 0,0
    l1,l2,r1,r2 = 0,0,0,0
    last1,last2 = 0,0
    st = 0
    for i in range(n):
        st += newv[i]
        if st == 0:
            cnt += 1
            cnt1 = -1
            last1 = i+1

        elif st == 1:
            cnt1 += 1
            if cnt1 >= maxv1:
                maxv1 = cnt1
                l1 = last1
                r1 = i+1

            last2 = i+1
            cnt2 = -1
        elif st == 2:
            cnt2 += 1
            if cnt2 >= maxv2:
                maxv2 = cnt2
                l2 = last2
                r2 = i+1
    if maxv1 == 0:
        print cnt
        print 1,1
    elif maxv1>maxv2+cnt:
        print maxv1+1
        print find(l1,maxi),find(r1,maxi)
    else:
        print maxv2+cnt+1
        print find(l2,maxi),find(r2,maxi)

n = int(input())
s = list(input())

best = 0
L = 1
R = 1
if n % 2:
    print(best)
    print(L, R)
    quit()
def check():
	calc = 0
	min = 0
	cntmin = 0
	for ch in s:
		if ch == '(':
			calc += 1
		else:
			calc -= 1
		if min > calc:
			min = calc
			cntmin = 1
		elif min == calc:
			cntmin += 1
	return cntmin if calc == 0 else 0

best = check()
for i, ch in enumerate(s, 0):
	for j in range(i + 1, n, 1):
		s[i], s[j] = s[j], s[i]
		new = check()
		s[j], s[i] = s[i], s[j]
		if (new > best):
			best = new; L = 1+i; R = 1+j
print(best)
print(L, R)

n = int(input())
s = list(input())

best = 0
L = 1
R = 1
def check():
	calc = 0
	min = 0
	cntmin = 0
	for ch in s:
		if ch == '(':
			calc += 1
		else:
			calc -= 1
		if min > calc:
			min = calc
			cntmin = 1
		elif min == calc:
			cntmin += 1
	return cntmin if calc == 0 else 0

best = check()
for i, ch in enumerate(s, 0):
	for j in range(i + 1, n, 1):
		s[i], s[j] = s[j], s[i]
		new = check()
		s[j], s[i] = s[i], s[j]
		if (new > best):
			best = new; L = 1+i; R = 1+j
print(best)
print(L, R)

n=int(input())
s=list(input())
def call(x):
    if x=='(':
        return 1
    else:
        return -1
s=list(map(call,s))
if sum(s)!=0:
    print(0)
    print(1,1)
else:
    ans=0
    pr=(1,1)
    for i in range(n-1):
        for j in range(i,n):
            lm=10**9
            sm=0
            ct=0
            s[i],s[j]=s[j],s[i]
            for k in range(n):
                sm+=s[k]
                if sm<lm:
                    lm=sm
                    ct=1
                elif sm==lm:
                    ct+=1
            if ct>ans:
                ans=ct
                pr=(i+1,j+1)
            s[i],s[j]=s[j],s[i]
    print(ans)
    print(*pr)

n=int(input())
s=input()
maxn=-1
if(n==1):
    print(0)
    print(1,1)
    exit(0)
for i in range(n):
    for j in range(i+1,n):
        s1=s[:i]+s[j]+s[i+1:j]+s[i]+s[j+1:]
        num=0
        temp=0
        min=501
        '''for k in range(1,n+1):
            s2=s1[n-k:]+s1[:n-k]
            while("()" in s2):
                s2=s2.replace("()","")
            if(s2==""):
                num+=1'''
        for k in range(n):
            if(s1[k]=='('):
                temp+=1
            else:
                temp-=1
            if(temp<min):
                min=temp
                num=1
            elif(temp==min):
                num+=1
        if(temp!=0):
            print(0)
            print(1,1)
            exit(0)
        if(num>maxn):
            maxn=num
            ansi=i+1
            ansj=j+1
print(maxn)
print(ansi,ansj)

n = int(input().strip())
s= input().strip()
ss= 0
mina = 0
ti = 0
for k in range(len(s)):
    if(s[k] == "("):
        ss+=1
    else:
        ss-=1
    if(ss<0):
        ti = k+1
        ss = 0
s=s[ti:]+s[:ti]
ss= 0
for k in range(len(s)):
    if(s[k] == "("):
        ss+=1
    else:
        ss-=1
    if(ss<0):
        print(0)
        print(1,1)
        break
else:
    if(ss == 0):
      pre=[0 for k in range(len(s))]
      for k  in range(len(s)):
          if (s[k] == "("):
              ss += 1
          else:
              ss -= 1
          pre[k] = ss
      tt = 0
      a =(1,1)
      for k in range(0,len(s)):
          if(pre[k] == 0):
              tt+=1
      maxi= tt
      g =0
      gg =0
      while(gg<len(s)):
          if(pre[gg] == 0):
                  if(gg != g+1):
                      yy = g+1
                      y = g+1
                      q = 0
                      while(yy<gg):
                          if(pre[yy] == 1):
                              if(yy !=y+1):
                                  rr = y+1
                                  r  = y+1
                                  h = 0
                                  while(rr<yy):
                                      if(pre[rr] == 2):
                                          h+=1
                                      rr+=1

                                  if(tt+h+1>maxi):
                                      maxi = tt + h + 1
                                      a=(y,yy)
                              q+=1
                              y = yy+1
                              yy = y
                          else:
                              yy+=1

                      if (q + 1 > maxi):
                          maxi = q+1
                          a = (g, gg)
                  g= gg+1
                  gg= g
          else:
               gg+=1
      print(maxi)
      print((a[0]+ti)%len(s)+1,(a[1]+ti)%len(s)+1)

    else:
        print(0)
        print(1,1)

from collections import deque
def getAnsRight(a):
        stack = deque()
        ans = 0
        for i in range(len(a)):
            if a[i] == '(':
                stack.append(a[i])
            else:
                stack.pop()
            if not len(stack):
                ans += 1
        return ans

def getAnsRighnt(a):
    stack = deque()
    indClose = -1
    indOpen = -1
    for i in range(len(a)):
        if a[i] == '(':
            stack.append((a[i], i))
        if a[i] == ')':
            if len(stack) == 0:
                indClose = i
            else:
                stack.pop()
    if len(stack):
        indOpen = stack.popleft()[1]

    if indOpen == -1 and indClose == -1:
        return getAnsRight(a)
    return 1 + getAnsRight(a[indClose+1:indOpen])

def getPer(a, i, j):
    l = a[i]
    a[i] = a[j]
    a[j] = l
    sOpen = 0
    sClose = 0
    for i in range(len(a)):
        if a[i] == '(':
            sOpen += 1
        else:
            sClose += 1
    if sOpen != sClose:
        return 0
    return getAnsRighnt(a)

def kek():
    n = int(input())
    a = list(input())
    answr = getPer(a, 0, 0)
    indL = 0
    indR = 0
    for i in range(len(a)):
        for j in range(i+1, len(a)):
            if a[i] == a[j]:
                continue
            lastAnswer = answr
            answr = max(getPer(a.copy(), i, j), answr)
            if lastAnswer < answr:
                indL = i
                indR = j

    print(answr)
    print(indL+1, indR+1)
kek()

n = int(input())
s = list(input())

cnt_r = 0
cnt_l = 0
for i in range(n):
    if s[i] == ")":
        cnt_r += 1
    else:
        cnt_l += 1
if cnt_l != cnt_r:
    print(0)
    print(1, 1)
    exit()

pos_r = []
pos_l = []

for i in range(n):
    if s[i] == ")":
        pos_r.append(i)
    else:
        pos_l.append(i)

# no change
ans = 0
for i in [0]:
    for j in [0]:
        tmp_ans = 0
        tmp = s[0:]
        tmp[i], tmp[j] = tmp[j], tmp[i]
        cnt = 0
        offset = 0
        min_cnt = 0
        for num, k in enumerate(tmp):
            if k == ")":
                cnt -= 1
            else:
                cnt += 1
            if cnt < min_cnt:
                min_cnt = cnt
                offset = num+1
        cnt = 0
        for num, k in enumerate(tmp[offset:]+tmp[0:offset]):
            if k == ")":
                cnt += 1
            else:
                cnt -= 1
            if cnt == 0:
                tmp_ans += 1
        if ans < tmp_ans:
            ans = tmp_ans
            ind1 = i
            ind2 = j

for i in pos_r:
    for j in pos_l:
        tmp_ans = 0
        tmp = s[0:]
        tmp[i], tmp[j] = tmp[j], tmp[i]
        cnt = 0
        offset = 0
        min_cnt = 0
        for num, k in enumerate(tmp):
            if k == ")":
                cnt -= 1
            else:
                cnt += 1
            if cnt < min_cnt:
                min_cnt = cnt
                offset = num+1
        #print("".join(tmp), offset)
        #print("".join(tmp[offset:]+tmp[0:offset]))
        cnt = 0
        for num, k in enumerate(tmp[offset:]+tmp[0:offset]):
            if k == ")":
                cnt += 1
            else:
                cnt -= 1
            if cnt == 0:
                tmp_ans += 1
        if ans < tmp_ans:
            ans = tmp_ans
            ind1 = i
            ind2 = j
print(ans)
print(ind1+1, ind2+1)

n = int(input())
st = input()
s = [0 if c == "(" else 1 for c in st]
if n % 2 != 0 or sum(s) != n//2:
    print(0)
    print(1,1)
    exit(0)
maxx = 0
ind = (0,0)
maxshift = 0
for shift in range(n):
    stack = 0
    x1 = -1
    x2 = -1
    sumzero = 0
    for i,c in enumerate(s):
        if s[(i+shift)%n] == 0:
            stack+=1
        else:
            stack-=1
        if stack == 0:
            sumzero+=1
        if stack < 0:
            x1 = i
            break
    stack = 0
    for i in range(n-1, -1, -1):
        if s[(i+shift)%n] == 1:
            stack+=1
        else:
            stack-=1
        if stack < 0:
            x2 = i
            break
    if x1 == -1 and x2 == -1 and stack == 0:
        if sumzero > maxx:
            maxx=sumzero
            ind = (0,0)
    if x1 == -1 or x2 == -1 or x1 == x2:
        continue
    stack = 0
    corr = True
    ans = 0
    for i in range(n):
        c = s[(i+shift)%n]

        if i == x1 or i == x2:
            c = 1-c
        if c == 0:
            stack += 1
        else:
            stack -= 1
        if stack == 0:
            ans+=1
        if stack == -1:
            corr = False
            break

    if not corr or stack > 0:
        continue
    if ans > maxx:
        maxshift = shift
        maxx = ans
        ind = ((x1+shift)%n, (x2+shift)%n)
print(maxx)
print(ind[0]+1,ind[1]+1)

n = int(input())
s = input()
sl = list(s)

ans = 0
ai = [1,1]

if sl.count("(") == sl.count(")"):
    for i in range(n):
        for j in range(i+1, n):
            sl[i], sl[j] = sl[j], sl[i]
            b = 0
            p = 0
            minp = 0
            k = 0
            for kk in range(n):
                if sl[k] == "(":
                    p += 1
                else:
                    p -= 1
                    if p == minp:
                        b += 1
                    elif p < minp:
                        minp = p
                        b = 1
                k = (k+1) % n
            # print(sl,b,i,j,k,minp)
            if b > ans:
                ans = b
                ai = [i+1, j+1]
            sl[i], sl[j] = sl[j], sl[i]

print(ans)
print(ai[0], ai[1])

n = int(input())
s = list(input())

best = 0
L = 1
R = 1

def check():
	calc = 0
	min = 0
	cntmin = 0
	for ch in s:
		if ch == '(':
			calc += 1
		else:
			calc -= 1
		if min > calc:
			min = calc
			cntmin = 1
		elif min == calc:
			cntmin += 1
	return cntmin if calc == 0 else 0

if len(s) % 2:
	print(best)
	print(L, R)
	quit()

best = check()
for i, ch in enumerate(s, 0):
	for j in range(i + 1, n, 1):
		s[i], s[j] = s[j], s[i]
		new = check()
		s[j], s[i] = s[i], s[j]
		if (new > best):
			best = new; L = 1+i; R = 1+j
print(best)
print(L, R)

# import cProfile
def prefix(s):
    count = 0
    cur = 0
    m = 0
    for c in s:
        if c == '(':
            cur += 1
        else:
            cur -= 1
        if cur < m:
            m = cur
            count = 0
        if cur == m:
            count += 1
    return count

from collections import Counter
n = int(input())
s = list(input())
C = Counter(s)
if C['('] == C[')']:
    a, b, c = -1, -1, -1
    for l in range(n):
        for r in range(l, n):
            s[l], s[r] = s[r], s[l]
            abc = prefix(s)
            if abc > a:
                a = abc
                b = l
                c = r
            s[l], s[r] = s[r], s[l]
    print (a)
    print (b + 1, c + 1)
else:
    print (0)
    print (1, 1)

n = int(input())
S = list(input())
def count_all(s):
    cnt=0
    l_cnt=1
    for c in s[1:]:
        if c==')':
            l_cnt-=1
        else:
            l_cnt+=1
        if l_cnt==0:
            cnt+=1
    return cnt
if S==list('()'*(n//2)) or S==list(')'+'()'*(n//2-1)+'('):
    print(n // 2)
    print(1, 1)
else:
    res=0
    l,r =1,1
    lc=rc=0
    for c in S:
        if c=="(":
            lc+=1
        else:
            rc+=1
    if lc==rc:
        for i in range(n):
            for j in range(i,n):
                ss=S[:]
                if ss[i]==ss[j]:
                    continue
                ss[i],ss[j]=ss[j],ss[i]
                t=0
                t_min=n
                m=0
                for k in range(n):
                    if ss[k]==")":
                        t-=1
                    else:
                        t+=1
                    if t<t_min:
                        t_min,m=t,k
                sss=ss[m+1:]+ss[:m+1]
                temp = count_all(sss)
                if temp>=res:
                    # print(sss)
                    res=temp
                    l,r=i+1,j+1
    print(res)
    print(l,r)

n = int(input())
ddd = input()
d = [0]
for dd in ddd:
    if dd == '(':
        d.append(d[-1] + 1)
    else:
        d.append(d[-1] - 1)
if d[-1] != 0:
    print("0\n1 1")
    exit(0)

d.pop()
mn = min(d)
ind = d.index(mn)
d = d[ind:] + d[:ind]
d = [i - mn for i in d]

fi = -1
crfi = -1
li = -1
mx = 0
cr = 0
cnt0 = 0
for i in range(n):
    dd = d[i]
    if dd == 0:
        cnt0 += 1
    if dd == 2:
        if cr == 0:
            crfi = i
        cr += 1
        if cr > mx:
            fi = crfi
            li = i
            mx = cr
    elif dd < 2:
        cr = 0

# print('=========')
# print(d)
# print(cnt0)
# print(fi, li)
# print(mx)
# print("=========")

# if fi == -1:
#     print(cnt0)
#     print(1, 1)
# else:
#     print(cnt0 + mx)
#     print(fi, li + 2)
if fi == -1:
    ans1 = [cnt0, 0, 0]
else:
    ans1 = [cnt0 + mx, fi-1, li]

fi = -1
crfi = -1
li = -1
mx = 0
cr = 0
for i in range(n):
    dd = d[i]
    if dd == 1:
        if cr == 0:
            crfi = i
        cr += 1
        if cr > mx:
            fi = crfi
            li = i
            mx = cr
    elif dd < 1:
        cr = 0

ans2 = [mx, fi-1, li]

if ans1[0] > ans2[0]:
    print(ans1[0])
    print(((ans1[1] + ind)%n) + 1, ((ans1[2] + ind)%n) + 1)
else:
    print(ans2[0])
    print(((ans2[1] + ind)%n) + 1, ((ans2[2] + ind)%n) + 1)

n = int(input())
s = list(input())
r = -1
l = n
root = []

def find_right(node):
    global l,r,s,n
    while n:
        r += 1
        n -= 1
        if s[r] == '(':
            node[2].append([r,-1,[]])
            find_right(node[2][-1])
        else:
            node[1] = r
            return True
    return False

def find_left(node):
    global l,r,s,n
    while n:
        l -= 1
        n -= 1
        if s[l] == ')':
            node[2].append([-1,l,[]])
            find_left(node[2][-1])
        else:
            node[0] = l
            return True
    return False

is_correct = True
while n:
    r += 1
    n -= 1
    if s[r]=='(':
        root.append([r,-1,[]])
        is_correct &= find_right(root[-1])
    else:
        root = [[-1,r,root]]
        is_correct &= find_left(root[-1])

sol = [[0,1,1]]
if is_correct:
    sol.append([len(root), 1, 1])
    for child in root:
        sol.append([len(child[2])+1, child[0]+1, child[1]+1])
        for gr_child in child[2]:
            if len(gr_child[2]):
                sol.append([len(root)+len(gr_child[2])+1, gr_child[0]+1, gr_child[1]+1])

print('%d\n%d %d'%tuple(max(sol)))

n = int(input())
s = list(input())

if n % 2 == 1 or s.count('(') != s.count(')'):
    print('0\n1 1')
    exit()

def solve():
    cnt_open, res, need = 0, 0, 0
    for i in s:
        if i == '(':
            cnt_open += 1
        else:
            cnt_open -= 1
            if cnt_open < need:
                need = cnt_open
                res = 1
            elif cnt_open == need:
                res += 1
    return res

res, res_i, res_j = solve(), 0, 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] != s[j]:
            s[i], s[j] = s[j], s[i]
            curr = solve()
            s[i], s[j] = s[j], s[i]
            if curr > res:
                res = curr
                res_i = i
                res_j = j
print(res)
print(res_i+1, res_j+1)

def get_bal():
    bal = [0] * n
    bal[0] = u[0]
    for i in range(1, n):
        bal[i] = bal[i - 1] + u[i]
    min_b = min(bal)
    ans = 0
    for i in range(n):
        if bal[i] == min_b:
            ans += 1
    return ans

n = int(input())
u = list(input())
for i in range(n):
    if u[i] == '(':
        u[i] = 1
    else:
        u[i] = -1
if sum(u) != 0:
    print(0)
    print(1, 1)
    exit()
ind = (-1, -1)
ans = -1
for i in range(n):
    for j in range(i, n):
        u[i], u[j] = u[j], u[i]
        ans_i = get_bal()
        u[i], u[j] = u[j], u[i]
        if ans_i > ans:
            ans = ans_i
            ind = (i + 1, j + 1)
print(ans)
print(ind[0], ind[1])

n = int(input())
s = list(input())
r = -1
l = n
root = []

def find_right(node):
    global l,r,s,n
    while n:
        r += 1
        n -= 1
        if s[r] == '(':
            node[2].append([r,-1,[]])
            find_right(node[2][-1])
        else:
            node[1] = r
            return True
    return False

def find_left(node):
    global l,r,s,n
    while n:
        l -= 1
        n -= 1
        if s[l] == ')':
            node[2].append([-1,l,[]])
            find_left(node[2][-1])
        else:
            node[0] = l
            return True
    return False

is_correct = True
while n:
    r += 1
    n -= 1
    if s[r]=='(':
        root.append([r,-1,[]])
        is_correct &= find_right(root[-1])
    else:
        root = [[-1,r,root]]
        is_correct &= find_left(root[-1])

b = [1,1]
if is_correct:
    m = len(root)
    for node in root:
        if (len(node[2])+1) > len(root):
            b = [node[0]+1, node[1]+1]
            m = len(node[2]) + 1
else:
    m = 0
print('%d\n%d %d'%(m, b[0],b[1]))

n = int(input())
s = list(input())
r = -1
l = n
root = []

def find_right(node):
    global l,r,s,n
    while n:
        r += 1
        n -= 1
        if s[r] == '(':
            node[2].append([r,-1,[]])
            find_right(node[2][-1])
        else:
            node[1] = r
            return True
    return False

def find_left(node):
    global l,r,s,n
    while n:
        l -= 1
        n -= 1
        if s[l] == ')':
            node[2].append([-1,l,[]])
            find_left(node[2][-1])
        else:
            node[0] = l
            return True
    return False

is_correct = True
while n:
    r += 1
    n -= 1
    if s[r]=='(':
        root.append([r,-1,[]])
        is_correct &= find_right(root[-1])
    else:
        root = [[-1,r,root]]
        is_correct &= find_left(root[-1])

sol = [[0,1,1]]
if is_correct:
    m = len(root)
    for child in root:
        sol.append([len(child[2])+1, child[0]+1, child[1]+1])
        for gr_child in child[2]:
            if len(gr_child[2]):
                sol.append([len(root)+len(gr_child[2])+1, gr_child[0]+1, gr_child[1]+1])

print('%d\n%d %d'%tuple(max(sol)))

from sys import stdin
from collections import deque
# https://codeforces.com/contest/1354/status/D
mod = 10**9 + 7
import sys
import random
# sys.setrecursionlimit(10**6)
from queue import PriorityQueue
# def rl():
#     return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt,factorial,gcd,log2,inf,ceil
# map(int,input().split())
# # l = list(map(int,input().split()))
# from itertools import permutations
import heapq
# input = lambda: sys.stdin.readline().rstrip()
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

# def ncr(x, y):
#     return f(x) // (f(y) * f(x - y))
def ncr(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den,
                      p - 2, p)) % p

import sys

# input = sys.stdin.readline
# LCA
# def bfs(na):
#
#     queue = [na]
#     boo[na] = True
#     level[na] = 0
#
#     while queue!=[]:
#
#         z = queue.pop(0)
#
#         for i in hash[z]:
#
#             if not boo[i]:
#
#                 queue.append(i)
#                 level[i] = level[z] + 1
#                 boo[i] = True
#                 dp[i][0] = z
#
#
#
# def prec(n):
#
#     for i in range(1,20):
#
#         for j in range(1,n+1):
#             if dp[j][i-1]!=-1:
#                 dp[j][i] = dp[dp[j][i-1]][i-1]
#
#
# def lca(u,v):
#     if level[v] < level[u]:
#         u,v = v,u
#
#     diff = level[v] - level[u]
#
#
#     for i in range(20):
#         if ((diff>>i)&1):
#             v = dp[v][i]
#
#
#     if u == v:
#         return u
#
#
#     for i in range(19,-1,-1):
#         # print(i)
#         if dp[u][i] != dp[v][i]:
#
#             u = dp[u][i]
#             v = dp[v][i]
#
#
#     return dp[u][0]
#
# dp = []
#
#
# n = int(input())
#
# for i in range(n + 10):
#
#     ka = [-1]*(20)
#     dp.append(ka)

# class FenwickTree:
#     def __init__(self, x):
#         """transform list into BIT"""
#         self.bit = x
#         for i in range(len(x)):
#             j = i | (i + 1)
#             if j < len(x):
#                 x[j] += x[i]
#
#     def update(self, idx, x):
#         """updates bit[idx] += x"""
#         while idx < len(self.bit):
#             self.bit[idx] += x
#             idx |= idx + 1
#
#     def query(self, end):
#         """calc sum(bit[:end])"""
#         x = 0
#         while end:
#             x += self.bit[end - 1]
#             end &= end - 1
#         return x
#
#     def find_kth_smallest(self, k):
#         """Find largest idx such that sum(bit[:idx]) <= k"""
#         idx = -1
#         for d in reversed(range(len(self.bit).bit_length())):
#             right_idx = idx + (1 << d)
#             if right_idx < len(self.bit) and k >= self.bit[right_idx]:
#                 idx = right_idx
#                 k -= self.bit[idx]
#         return idx + 1

# import sys
# def rs(): return sys.stdin.readline().strip()
# def ri(): return int(sys.stdin.readline())
# def ria(): return list(map(int, sys.stdin.readline().split()))
# def prn(n): sys.stdout.write(str(n))
# def pia(a): sys.stdout.write(' '.join([str(s) for s in a]))
#
#
# import gc, os
#
# ii = 0
# _inp = b''
#
#
# def getchar():
#     global ii, _inp
#     if ii >= len(_inp):
#         _inp = os.read(0, 100000)
#         gc.collect()
#         ii = 0
#     if not _inp:
#         return b' '[0]
#     ii += 1
#     return _inp[ii - 1]
#
#
# def input():
#     c = getchar()
#     if c == b'-'[0]:
#         x = 0
#         sign = 1
#     else:
#         x = c - b'0'[0]
#         sign = 0
#     c = getchar()
#     while c >= b'0'[0]:
#         x = 10 * x + c - b'0'[0]
#         c = getchar()
#     if c == b'\r'[0]:
#         getchar()
#     return -x if sign else x

# fenwick Tree

# n,q = map(int,input().split())
#
#
# l1 = list(map(int,input().split()))
#
# l2 = list(map(int,input().split()))
#
# bit = [0]*(10**6 + 1)
#
# def update(i,add,bit):
#
#     while i>0 and i<len(bit):
#
#         bit[i]+=add
#         i = i + (i&(-i))
#
#
# def sum(i,bit):
#     ans = 0
#     while i>0:
#
#         ans+=bit[i]
#         i = i - (i & ( -i))
#
#
#     return ans
#
# def find_smallest(k,bit):
#
#     l = 0
#     h = len(bit)
#     while l<h:
#
#         mid = (l+h)//2
#         if k <= sum(mid,bit):
#             h = mid
#         else:
#             l = mid + 1
#
#
#     return l
#
#
# def insert(x,bit):
#     update(x,1,bit)
#
# def delete(x,bit):
#     update(x,-1,bit)
# fa = set()
#
# for i in l1:
#     insert(i,bit)
#
#
# for i in l2:
#     if i>0:
#         insert(i,bit)
#
#     else:
#         z = find_smallest(-i,bit)
#
#         delete(z,bit)
#
#
# # print(bit)
# if len(set(bit)) == 1:
#     print(0)
# else:
#     for i in range(1,n+1):
#         z = find_smallest(i,bit)
#         if z!=0:
#             print(z)
#             break
#

# service time problem

# def solve2(s,a,b,hash,z,cnt):
#     temp = cnt.copy()
#     x,y = hash[a],hash[b]
#     i = 0
#     j = len(s)-1
#
#     while z:
#
#         if s[j] - y>=x-s[i]:
#             if temp[s[j]]-1 == 0:
#                 j-=1
#             temp[s[j]]-=1
#             z-=1
#
#
#         else:
#             if temp[s[i]]-1 == 0:
#                 i+=1
#
#             temp[s[i]]-=1
#             z-=1
#
#     return s[i:j+1]
#
#
#
#
#
# def solve1(l,s,posn,z,hash):
#
#     ans = []
#     for i in l:
#         a,b = i
#         ka = solve2(s,a,b,posn,z,hash)
#         ans.append(ka)
#
#         return ans
#
# def consistent(input, window, min_entries, max_entries, tolerance):
#
#     l = input
#     n = len(l)
#     l.sort()
#     s = list(set(l))
#     s.sort()
#
#     if min_entries<=n<=max_entries:
#
#         if s[-1] - s[0]<window:
#             return True
#         hash = defaultdict(int)
#         posn = defaultdict(int)
#         for i in l:
#             hash[i]+=1
#
#         z = (tolerance*(n))//100
#         poss_window = set()
#
#
#         for i in range(len(s)):
#                 posn[i] = l[i]
#                 for j in range(i+1,len(s)):
#                     if s[j]-s[i] == window:
#                         poss_window.add((s[i],s[j]))
#
#         if poss_window!=set():
#             print(poss_window)
#             ans = solve1(poss_window,s,posn,z,hash)
#             print(ans)
#
#
#         else:
#             pass
#
#     else:
#         return False
#
#
#
#
# l = list(map(int,input().split()))
#
# min_ent,max_ent = map(int,input().split())
# w = int(input())
# tol = int(input())
# consistent(l, w, min_ent, max_ent, tol)

# t = int(input())
#
# for i in range(t):
#
#     n,x = map(int,input().split())
#
#     l = list(map(int,input().split()))
#
#     e,o = 0,0
#
#     for i in l:
#         if i%2 == 0:
#             e+=1
#         else:
#             o+=1
#
#     if e+o>=x and o!=0:
#         z = e+o - x
#         if z == 0:
#             if o%2 == 0:
#                 print('No')
#             else:
#                 print('Yes')
#             continue
#         if o%2 == 0:
#             o-=1
#             z-=1
#             if e>=z:
#                 print('Yes')
#             else:
#                 z-=e
#                 o-=z
#                 if o%2!=0:
#                     print('Yes')
#                 else:
#                     print('No')
#
#         else:
#
#             if e>=z:
#                 print('Yes')
#             else:
#                 z-=e
#                 o-=z
#                 if o%2!=0:
#                     print('Yes')
#                 else:
#                     print('No')
#     else:
#         print('No')
#
#
#
#
#
#
#
# def dfs(n):
#     boo[n] = True
#     dp2[n] = 1
#     for i in hash[n]:
#         if not boo[i]:
#
#             dfs(i)
#             dp2[n] += dp2[i]

n = int(input())

s = list(input())
ans = 0
x,y = 1,1
for i in range(n):
    for j in range(i+1,n):
        s[i],s[j] = s[j],s[i]
        stack = []
        cnt = 0
        flag = 0
        for k in range(n):
          if s[k] == '(':
              stack.append('(')
          else:
              if stack!=[]:
                  stack.pop()
                  if stack == []:
                      cnt+=1
              else:
                   flag = -1
                   break
        if flag == 0:
            ans = max(cnt,ans)
            if ans == cnt:
                x,y = i+1,j+1

        s[i],s[j] = s[j],s[i]

print(ans)
print(x,y)

n=int(input())
s=input()
maxn=-1
if(n==1):
    print(0)
    print(1,1)
    exit(0)
for i in range(n):
    for j in range(i+1,n):
        s1=s[:i]+s[j]+s[i+1:j]+s[i]+s[j+1:]
        num=0
        temp=0
        min=501
        '''for k in range(1,n+1):
            s2=s1[n-k:]+s1[:n-k]
            while("()" in s2):
                s2=s2.replace("()","")
            if(s2==""):
                num+=1'''
        for k in range(n):
            if(s1[k]=='('):
                temp+=1
            else:
                temp-=1
            if(temp<min):
                min=temp
                num=1
            elif(temp==min):
                num+=1
        if(num>maxn):
            maxn=num
            ansi=i+1
            ansj=j+1
print(maxn)
print(ansi,ansj)

n = int(input().strip())
s= input().strip()
ss= 0
mina = 0
ti = 0
for k in range(len(s)):
    if(s[k] == "("):
        ss+=1
    else:
        ss-=1
    if(ss<0):
        ti = k+1
        ss = 0
s=s[ti:]+s[:ti]
print(s)
ss= 0
for k in range(len(s)):
    if(s[k] == "("):
        ss+=1
    else:
        ss-=1
    if(ss<0):
        print(0)
        print(1,1)
        break
else:
    if(ss == 0):
      pre=[0 for k in range(len(s))]
      for k  in range(len(s)):
          if (s[k] == "("):
              ss += 1
          else:
              ss -= 1
          pre[k] = ss
      tt = 0
      a =(1,1)
      for k in range(0,len(s)):
          if(pre[k] == 0):
              tt+=1
      maxi= tt
      g =0
      gg =0
      while(gg<len(s)):
          if(pre[gg] == 0):
                  if(gg != g+1):
                      yy = g+1
                      y = g+1
                      q = 0
                      while(yy<gg):
                          if(pre[yy] == 1):
                              if(yy !=y+1):
                                  rr = y+1
                                  r  = y+1
                                  h = 0
                                  while(rr<yy):
                                      if(pre[rr] == 2):
                                          h+=1
                                      rr+=1

                                  if(tt+h+1>maxi):
                                      maxi = tt + h + 1
                                      a=(y,yy)
                              q+=1
                              y = yy+1
                              yy = y
                          else:
                              yy+=1

                      if (q + 1 > maxi):
                          maxi = q+1
                          a = (g, gg)
                  g= gg+1
                  gg= g
          else:
               gg+=1
      print(maxi)
      print((a[0]+ti)%len(s)+1,(a[1]+ti)%len(s)+1)

    else:
        print(0)
        print(1,1)

from collections import deque
def getAnsRight(a):
        stack = deque()
        ans = 0
        for i in range(len(a)):
            if a[i] == '(':
                stack.append(a[i])
            else:
                stack.pop()
            if not len(stack):
                ans += 1
        return ans

def getAnsRighnt(a):
    stack = deque()
    indClose = -1
    indOpen = -1
    for i in range(len(a)):
        if a[i] == '(':
            stack.append((a[i], i))
        if a[i] == ')':
            if len(stack) == 0:
                indClose = i
            else:
                stack.pop()
    if len(stack):
        indOpen = stack.popleft()[1]

    if indOpen == -1 and indClose == -1:
        return getAnsRight(a)
    return 1 + getAnsRight(a[indClose+1:indOpen])

def getPer(a, i, j):
    l = a[i]
    a[i] = a[j]
    a[j] = l
    sOpen = 0
    sClose = 0
    for i in range(len(a)):
        if a[i] == '(':
            sOpen += 1
        else:
            sClose += 1
    if sOpen != sClose:
        return 0
    return getAnsRighnt(a)

def kek():
    n = int(input())
    a = list(input())
    answr = getAnsRighnt(a)
    indL = 0
    indR = 0
    for i in range(len(a)):
        for j in range(i+1, len(a)):
            if a[i] == a[j]:
                continue
            lastAnswer = answr
            answr = max(getPer(a.copy(), i, j), answr)
            if lastAnswer < answr:
                indL = i
                indR = j

    print(answr)
    print(indL+1, indR+1)
kek()

from collections import deque
def getAnsRight(a):
        stack = deque()
        ans = 0
        for i in range(len(a)):
            if a[i] == '(':
                stack.append(a[i])
            else:
                stack.pop()
            if not len(stack):
                ans += 1
        return ans

def getAnsRighnt(a):
    stack = deque()
    indClose = -1
    indOpen = -1
    for i in range(len(a)):
        if a[i] == '(':
            stack.append((a[i], i))
        if a[i] == ')':
            if len(stack) == 0:
                indClose = i
            else:
                stack.pop()
    if len(stack):
        indOpen = stack.popleft()[1]

    if indOpen == -1 and indClose == -1:
        return getAnsRight(a)
    return 1 + getAnsRight(a[indClose+1:indOpen])

def getPer(a, i, j):
    l = a[i]
    a[i] = a[j]
    a[j] = l
    sOpen = 0
    sClose = 0
    for i in range(len(a)):
        if a[i] == '(':
            sOpen += 1
        else:
            sClose += 1
    if sOpen != sClose:
        return 0
    return getAnsRighnt(a)

n = int(input())
a = list(input())
answr = 0
indL = 0
indR = 0
for i in range(len(a)):
    for j in range(i, len(a)):
        lastAnswer = answr
        answr = max(getPer(a.copy(), i, j), answr)
        if lastAnswer < answr:
            indL = i
            inrR = j

print(answr)
print(indL, indR)

from collections import deque
def getAnsRight(a):
        stack = deque()
        ans = 0
        for i in range(len(a)):
            if a[i] == '(':
                stack.append(a[i])
            else:
                stack.pop()
            if not len(stack):
                ans += 1
        return ans

def getAnsRighnt(a):
    stack = deque()
    indClose = -1
    indOpen = -1
    for i in range(len(a)):
        if a[i] == '(':
            stack.append((a[i], i))
        if a[i] == ')':
            if len(stack) == 0:
                indClose = i
            else:
                stack.pop()
    if len(stack):
        indOpen = stack.popleft()[1]

    if indOpen == -1 and indClose == -1:
        return getAnsRight(a)
    return 1 + getAnsRight(a[indClose+1:indOpen])

def getPer(a, i, j):
    l = a[i]
    a[i] = a[j]
    a[j] = l
    sOpen = 0
    sClose = 0
    for i in range(len(a)):
        if a[i] == '(':
            sOpen += 1
        else:
            sClose += 1
    if sOpen != sClose:
        return 0
    return getAnsRighnt(a)

def kek():
    n = int(input())
    a = list(input())
    answr = 0
    indL = 0
    indR = 0
    for i in range(len(a)):
        for j in range(i+1, len(a)):
            if a[i] == a[j]:
                continue
            lastAnswer = answr
            answr = max(getPer(a.copy(), i, j), answr)
            if lastAnswer < answr:
                indL = i
                indR = j

    print(answr)
    print(indL+1, indR+1)
kek()

from collections import deque
def getAnsRight(a):
        stack = deque()
        ans = 0
        for i in range(len(a)):
            if a[i] == '(':
                stack.append(a[i])
            else:
                stack.pop()
            if not len(stack):
                ans += 1
        return ans

def getAnsRighnt(a):
    stack = deque()
    indClose = -1
    indOpen = -1
    for i in range(len(a)):
        if a[i] == '(':
            stack.append((a[i], i))
        if a[i] == ')':
            if len(stack) == 0:
                indClose = i
            else:
                stack.pop()
    if len(stack):
        indOpen = stack.popleft()[1]

    if indOpen == -1 and indClose == -1:
        return getAnsRight(a)
    return 1 + getAnsRight(a[indClose+1:indOpen])

def getPer(a, i, j):
    l = a[i]
    a[i] = a[j]
    a[j] = l
    sOpen = 0
    sClose = 0
    for i in range(len(a)):
        if a[i] == '(':
            sOpen += 1
        else:
            sClose += 1
    if sOpen != sClose:
        return 0
    return getAnsRighnt(a)

n = int(input())
a = list(input())
answr = 0
indL = 0
indR = 0
for i in range(len(a)):
    for j in range(i, len(a)):
        lastAnswer = answr
        answr = max(getPer(a.copy(), i, j), answr)
        if lastAnswer < answr:
            indL = i
            inrR = j

print(answr)
print(indL+1, indR+1)

n = int(input())
s = list(input())

cnt_r = 0
cnt_l = 0
for i in range(n):
    if s[i] == ")":
        cnt_r += 1
    else:
        cnt_l += 1
if cnt_l != cnt_r:
    print(0)
    print(1, 1)
    exit()

pos_r = []
pos_l = []

for i in range(n):
    if s[i] == ")":
        pos_r.append(i)
    else:
        pos_l.append(i)

ans = 0
for i in pos_r:
    for j in pos_l:
        tmp_ans = 0
        tmp = s[0:]
        tmp[i], tmp[j] = tmp[j], tmp[i]
        cnt = 0
        offset = 0
        min_cnt = 0
        for num, k in enumerate(tmp):
            if k == ")":
                cnt -= 1
            else:
                cnt += 1
            if cnt < min_cnt:
                min_cnt = cnt
                offset = num+1
        #print("".join(tmp), offset)
        #print("".join(tmp[offset:]+tmp[0:offset]))
        cnt = 0
        for num, k in enumerate(tmp[offset:]+tmp[0:offset]):
            if k == ")":
                cnt += 1
            else:
                cnt -= 1
            if cnt == 0:
                tmp_ans += 1
        if ans < tmp_ans:
            ans = tmp_ans
            ind1 = i
            ind2 = j
print(ans)
print(ind1+1, ind2+1)

n = int(input())
st = input()
s = [0 if c == "(" else 1 for c in st]
maxx = 0
ind = (0,0)
maxshift = 0
for shift in range(n):
    stack = 0
    x1 = -1
    x2 = -1
    for i,c in enumerate(s):
        if s[(i+shift)%n] == 0:
            stack+=1
        else:
            stack-=1
        if stack < 0:
            x1 = i
            break
    stack = 0
    for i in range(n-1, -1, -1):
        if s[(i+shift)%n] == 1:
            stack+=1
        else:
            stack-=1
        if stack < 0:
            x2 = i
            break
    if x1 == -1 or x2 == -1 or x1 == x2:
        continue
    stack = 0
    corr = True
    ans = 0
    for i in range(n):
        c = s[(i+shift)%n]

        if i == x1 or i == x2:
            c = 1-c
        if c == 0:
            stack += 1
        else:
            stack -= 1
        if stack == 0:
            ans+=1
        if stack == -1:
            corr = False
            break

    if not corr or stack > 0:
        continue
    if ans > maxx:
        maxshift = shift
        maxx = ans
        ind = ((x1+shift)%n, (x2+shift)%n)
print(maxx)
print(ind[0]+1,ind[1]+1)

n = int(input())
s = input()
sl = list(s)

ans = 0
ai = [1,1]

for i in range(n):
    for j in range(i, n):
        sl = list(s)
        sl[i], sl[j] = sl[j], sl[i]
        b = 0
        p = 0
        k = 0
        while k < n and sl[k] == ")":
            k += 1
        for kk in range(n):
            if sl[k] == "(":
                p += 1
            else:
                if p == 1:
                    b += 1
                elif p == 0:
                    b = 0
                    break
                p -= 1
            k = (k+1) % n
        # print(sl,b,i,j)
        if b > ans:
            ans = b
            ai = [i+1, j+1]

print(ans)
print(ai[0], ai[1])

n = int(input())
s = input()
sl = list(s)

ans = 0
ai = [1,1]

for i in range(n):
    for j in range(i, n):
        sl = list(s)
        sl[i], sl[j] = sl[j], sl[i]
        b = 0
        p = 0
        k = 0
        while k < n and sl[k] == ")":
            k += 1
        k %= n
        for kk in range(n):
            if sl[k] == "(":
                p += 1
            else:
                if p == 1:
                    b += 1
                elif p == 0:
                    b = 0
                    break
                p -= 1
            k = (k+1) % n
        # print(sl,b,i,j)
        if b > ans:
            ans = b
            ai = [i+1, j+1]

print(ans)
print(ai[0], ai[1])

def prefix(s):
    array = []
    for i in s:
        if i == '(':
            try:
                array.append(1 + array[-1])
            except:
                array.append(1)
        else:
            try:
                array.append(-1 + array[-1])
            except:
                array.append(-1)
    return array

def count_ok(s):
    array = prefix(s)
    if array[-1] != 0: return 0
    return array.count(min(array))

n = int(input())
s = list(input())
a, b, c = -1, -1, -1
for l in range(n - 1):
    for r in range(l + 1, n):
        t = s.copy()
        t[l], t[r] = t[r], t[l]
        abc = count_ok(t)
        if abc > a:
            a = abc
            b = l
            c = r
print (a)
print (b + 1, c + 1)

# import cProfile
def prefix(s):
    count = 0
    cur = 0
    m = 0
    for c in s:
        if c == '(':
            cur += 1
        else:
            cur -= 1
        if cur < m:
            m = cur
            count = 0
        if cur == m:
            count += 1
    return count

n = int(input())
s = list(input())
if n % 2 == 0:
    a, b, c = -1, -1, -1
    for l in range(n):
        for r in range(l, n):
            s[l], s[r] = s[r], s[l]
            abc = prefix(s)
            if abc > a:
                a = abc
                b = l
                c = r
            s[l], s[r] = s[r], s[l]
    print (a)
    print (b + 1, c + 1)
else:
    print (0)
    print (1, 1)

n = int(input())
S = list(input())
def count_all(s):
    cnt=0
    l_cnt=1
    for c in s[1:]:
        if c==')':
            l_cnt-=1
        else:
            l_cnt+=1
        if l_cnt==0:
            cnt+=1
    return cnt
res=0
l,r =1,1
lc=rc=0
for c in S:
    if c=="(":
        lc+=1
    else:
        rc+=1
if lc==rc:
    for i in range(n):
        for j in range(i,n):
            ss=S[:]
            if ss[i]==ss[j]:
                continue
            ss[i],ss[j]=ss[j],ss[i]
            t=0
            t_min=0
            m=0
            for k in range(n):
                if ss[k]==")":
                    t-=1
                else:
                    t+=1
                if t<=t_min:
                    t_min,m=t,k
            sss=ss[m+1:]+ss[:m+1]
            temp = count_all(sss)
            if temp>=res:
                # print(sss)
                res=temp
                l,r=i+1,j+1
print(res)
print(l,r)

n = int(input())
S = list(input())
def count_all(s):
    cnt=0
    l_cnt=1
    for c in s[1:]:
        if c==')':
            l_cnt-=1
        else:
            l_cnt+=1
        if l_cnt==0:
            cnt+=1
    return cnt
res=0
l,r =1,1
lc=rc=0
for c in S:
    if c=="(":
        lc+=1
    else:
        rc+=1
if lc==rc:
    for i in range(n):
        for j in range(i,n):
            ss=S[:]
            if ss[i]==ss[j]:
                continue
            ss[i],ss[j]=ss[j],ss[i]
            t=0
            t_min=0
            m=0
            nums=[0]*n
            for k in range(n):
                if ss[k]==")":
                    t-=1
                else:
                    t+=1
                nums[k]=t
                if t<=t_min:
                    t_min,m=t,k
            # sss=ss[m+1:]+ss[:m+1]
            # temp = count_all(sss)
            temp = len([a for a in nums if a==t_min])
            if temp>=res:
                # print(sss)
                res=temp
                l,r=i+1,j+1
print(res)
print(l,r)

n = int(input())
S = list(input())
def count_all(s):
    cnt=0
    l_cnt=1
    for c in s[1:]:
        if c==')':
            l_cnt-=1
        else:
            l_cnt+=1
        if l_cnt==0:
            cnt+=1
    return cnt
res=0
l,r =1,1
lc=rc=0
for c in S:
    if c=="(":
        lc+=1
    else:
        rc+=1
if lc==rc:
    for i in range(n):
        for j in range(i,n):
            ss=S[:]
            if ss[i]==ss[j]:
                continue
            ss[i],ss[j]=ss[j],ss[i]
            t=0
            t_min=n
            m=0
            for k in range(n):
                if ss[k]==")":
                    t-=1
                else:
                    t+=1
                if t<t_min:
                    t_min,m=t,k
            sss=ss[m+1:]+ss[:m+1]
            temp = count_all(sss)
            if temp>=res:
                # print(sss)
                res=temp
                l,r=i+1,j+1
print(res)
print(l,r)

n = int(input())
S = list(input())
def count_all(s):
    cnt=0
    l_cnt=1
    for c in s[1:]:
        if c==')':
            l_cnt-=1
        else:
            l_cnt+=1
        if l_cnt==0:
            cnt+=1
    return cnt
res=0
l,r =1,1
lc=rc=0
for c in S:
    if c=="(":
        lc+=1
    else:
        rc+=1

if lc==rc:
    for i in range(n):
        for j in range(i,n):
            ss=S[:]
            if ss[i]==ss[j]:
                continue
            ss[i],ss[j]=ss[j],ss[i]
            t=0
            t_min=n
            m=0
            for k in range(n):
                if ss[k]==")":
                    t-=1
                else:
                    t+=1
                if t<t_min:
                    t_min,m=t,k
            sss=ss[m+1:]+ss[:m+1]
            temp = count_all(sss)
            if temp>=res:
                # print(sss)
                res=temp
                l,r=i+1,j+1
if S!=list('()'*(n//2)):
    print(res)
    print(l,r)
else:
    print(n//2)
    print(1,1)

n = int(input())
S = list(input())

def count_all(s):
    cnt=0
    l_cnt=1
    for c in s[1:]:
        if c==')':
            l_cnt-=1
        else:
            l_cnt+=1
        if l_cnt==0:
            cnt+=1
    return cnt
if S!=list('()'*(n//2)) and S!=list(')'+'()'*(n//2-1)+'('):
    print(n // 2)
    print(1, 1)
else:
    res=0
    l,r =1,1
    lc=rc=0

    for c in S:
        if c=="(":
            lc+=1
        else:
            rc+=1

    if lc==rc:
        for i in range(n):
            for j in range(i,n):
                ss=S[:]
                if ss[i]==ss[j]:
                    continue
                ss[i],ss[j]=ss[j],ss[i]
                t=0
                t_min=n
                m=0
                for k in range(n):
                    if ss[k]==")":
                        t-=1
                    else:
                        t+=1
                    if t<t_min:
                        t_min,m=t,k
                sss=ss[m+1:]+ss[:m+1]
                temp = count_all(sss)
                if temp>=res:
                    # print(sss)
                    res=temp
                    l,r=i+1,j+1
    print(res)
    print(l,r)

N = 503 * 3
n = int(input())
s = input()

def solve(tmp):
    balance = [0] * N
    q = [0] * N

    for i in range(n):
        balance[i+1] += balance[i]
        if tmp[i] == '(':
            balance[i+1] += 1
        else:
            balance[i+1] -= 1

    if balance[0] != balance[n]:
        return 0

    for i in range(n):
        q[balance[i] + n] += 1
    for i in range(N):
        if q[i] != 0:
            return q[i]

res, res_i, res_j = 0, 0, 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] != s[j]:
            tmp = s[:i] + s[j:j+1] + s[i+1:j] + s[i:i+1] + s[j+1:]
            curr = solve(tmp)
            if curr > res:
                res = curr
                res_i = i
                res_j = j
print(res)
print(res_i+1, res_j+1)

n = int(input())
s = list(input())

def solve(x):
    cnt_open, res, need = 0, 0, 0
    for i in x:
        if i == '(':
            cnt_open += 1
        else:
            cnt_open -= 1
            if cnt_open < need:
                need = cnt_open
                res = 1
            elif cnt_open == need:
                res += 1
    return res

res, res_i, res_j = 0, 0, 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] != s[j]:
            s[i], s[j] = s[j], s[i]
            curr = solve(s)
            s[i], s[j] = s[j], s[i]
            if curr > res:
                res = curr
                res_i = i
                res_j = j
print(res)
print(res_i+1, res_j+1)

n = int(input())
s = list(input())

if n % 2 == 1 or s.count('(') != s.count(')'):
    print('0\n1 1')
    exit()

def solve():
    cnt_open, res, need = 0, 0, 0
    for i in s:
        if i == '(':
            cnt_open += 1
        else:
            cnt_open -= 1
            if cnt_open < need:
                need = cnt_open
                res = 1
            elif cnt_open == need:
                res += 1
    return res

res, res_i, res_j = 0, 0, 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] != s[j]:
            s[i], s[j] = s[j], s[i]
            curr = solve()
            s[i], s[j] = s[j], s[i]
            if curr > res:
                res = curr
                res_i = i
                res_j = j
print(res)
print(res_i+1, res_j+1)

N = int(input())
string = list(input())

def swap(arr, i, j):
    arr[i], arr[j] = arr[j], arr[i]

def calc(string):
    s = 0
    t = 0
    for char in string:
        if s == 0 and char == "(":
            t += 1

        if char == "(":
            s += 1
        elif char == ")":
            s -= 1

    if s == 0:
        return t
    else:
        return 0

highest = calc(string)
a = b = 0
for i in range(N):
    for j in range(i + 1, N):
        swap(string, i, j)
        total = calc(string)
        if total > highest:
            highest = total
            a, b = i, j
        swap(string, i, j)

print(highest)
print(a+1, b+1)

N = int(input())
string = list(input())

def swap(arr, i, j):
    arr[i], arr[j] = arr[j], arr[i]

def calc(string):
    s = 0
    t = 0
    for char in string:
        if s == 0 and char == "(":
            t += 1

        if char == "(":
            s += 1
        elif char == ")":
            s -= 1

    if s == 0:
        return t
    else:
        return 0

highest = 0
a = b = 0
for i in range(N):
    for j in range(i + 1, N):
        swap(string, i, j)
        total = calc(string)
        if total > highest:
            highest = total
            a, b = i, j
        swap(string, i, j)

print(highest)
print(a+1, b+1)

N = int(input())
string = list(input())

def swap(arr, i, j):
    arr[i], arr[j] = arr[j], arr[i]

def calc(string):
    s = 0
    t = 0
    prev = ""
    for char in string:
        if char == "(":
            s += 1
        elif char == ")":
            s -= 1
        if ((s == 0) or (s == 1 and prev != "(")) and char == "(":
            t += 1
        prev = char
    if s == 0:
        return t
    else:
        return 0

highest = calc(string)
a = b = 0
for i in range(N):
    for j in range(i + 1, N):
        swap(string, i, j)
        total = calc(string)
        if total > highest:
            highest = total
            a, b = i, j
        swap(string, i, j)

print(highest)
print(a+1, b+1)

import sys
input = sys.stdin.readline
def matcher(correcti):
    open_=0
    close_=0
    count=0
    excess=0
    for i in range(len(correcti)):
        if correcti[i]=='(':
            open_+=1
        if correcti[i]==')':
            close_+=1
        if close_>open_ and open_==0:
            excess+=1
            close_-=1
            count=0
            continue
        if open_==close_:
            count+=1
            open_=0
            close_=0
    if open_-close_==excess:
        return(count+1)
    else:
        return(0)
n=int(input())
l=[i for i in input() if i!='\n']
st=("".join(l).rstrip(')').rstrip('('))
swap=matcher(l[len(st):]+l[:len(st)])
#print(swap)
shifts=[[1,1]]
for i in range(n):
    for j in range(i,n):
        if l[i]!=l[j]:
            l[i],l[j]=l[j],l[i]
            output=(matcher(l))
            if output>swap:
                swap=output
                shifts[0]=[i+1,j+1]
            l[i],l[j]=l[j],l[i]
print(swap)
print(*shifts[0])

n = int(input())
seq = list(input())

def rectify(seq):
    depth = 0
    best = bestVal = -1
    for i in range(n):
        if seq[i] == "(":
            depth += 1
        else:
            depth -= 1
            if best == -1 or depth < bestVal:
                best = i
                bestVal = depth
    return seq[best+1:]+seq[:best+1]

if n%2 == 1 or seq.count("(") != seq.count(")"):
    print(0)
    print(1,1)
else:
    best = -1
    bestVal = -1
    for i in range(n):
        for j in range(n):
            if seq[i] != seq[j]:
                swapseq = list(seq)
                swapseq[i] = seq[j]
                swapseq[j] = seq[i]
                swapseq = rectify(swapseq)
                depth = components = 0
                for x in range(n):
                    if swapseq[x] == "(":
                        depth += 1
                    else:
                        depth -= 1
                        if depth == 0:
                            components += 1
                if bestVal == -1 or components > bestVal:
                    best = (i,j)
                    bestVal = components
    print(bestVal)
    print(best[0],best[1])

"""
NTC here
"""
from sys import stdin, setrecursionlimit
setrecursionlimit(10**7)

def iin(): return int(stdin.readline())

def lin(): return list(map(int, stdin.readline().split()))

# range = xrange
# input = raw_input

def bcheck(a,l,r):
    if a[l]==a[r]:return -1
    a1=a[:]
    a1[l],a1[r]=a1[r],a1[l]
    N=len(a)
    p,n=[],[]
    for i in range(N):
        if a1[i]==')':
            if p:
                p.pop()
            else:
                n.append(i)
        else:
            p.append(i)
    l=len(p)
    rt=0
    if l>0:
        rt=n[-1]+1
    if rt:
        a1=a1[rt:]+a1[:rt]
    ch,pt=0,0
    for i in a1:
        if i=='(':
            pt+=1
        else:
            pt-=1
        if pt==0:ch+=1
    #print(a1,ch)

    return ch

def main():
    N=iin()
    a=list(input())
    c1,c2=a.count(')'),a.count('(')
    if c1!=c2 or N%2:
        print(0)
        print(1,1)
    else:
        mx=[-1,0,0]
     #   print(a)
        for i in range(N):
            for j in range(i+1,N):
                if a[i]!=a[j]:
                    val=bcheck(a,i,j)
                    if mx[0]<val:
                        mx=[val,i,j]
      #  print(a)
        print(mx[0])
        print(mx[1]+1,mx[2]+1)

main()
# try:
#     main()
# except Exception as e: print(e)

"""
NTC here
"""
from sys import stdin, setrecursionlimit
setrecursionlimit(10**7)

def iin(): return int(stdin.readline())

def lin(): return list(map(int, stdin.readline().split()))

# range = xrange
# input = raw_input

def bcheck(a,l,r):
    if a[l]==a[r]:return -1
    a[l],a[r]=a[r],a[l]
    N=len(a)
    p,n=[],[]
    for i in range(N):
        if a[i]==')':
            if p:
                p.pop()
            else:
                n.append(i)
        else:
            p.append(i)
    l=len(p)
    rt=0
    if l>0:
        rt=n[-1]+1
    if rt:
        a=a[rt:]+a[:rt]
    ch,pt=0,0
    for i in a:
        if i=='(':
            pt+=1
        else:
            pt-=1
        if pt==0:ch+=1
    rt=N-rt
    a=a[rt:]+a[:rt]
    #print(a,ch)

    a[l],a[r]=a[r],a[l]
    return ch

def main():
    N=iin()
    a=list(input())
    c1,c2=a.count(')'),a.count('(')
    if c1!=c2 or N%2:
        print(0)
        print(1,1)
    else:
        mx=[-1,0,0]
        for i in range(N):
            for j in range(i+1,N):
                if a[i]!=a[j]:
                    val=bcheck(a,i,j)
                    if mx[0]<val:
                        mx=[val,i,j]
        print(mx[0])
        print(mx[1]+1,mx[2]+1)

main()
# try:
#     main()
# except Exception as e: print(e)

#!/usr/bin/env python3
import sys

#lines = stdin.readlines()
def rint():
    return map(int, sys.stdin.readline().split())

def input():
    return sys.stdin.readline().rstrip('\n')

def oint():
    return int(input())

n = oint()
stemp  = input()
s = []
for i in range(n):
    if stemp[i] == '(':
        s.append(1)
    else:
        s.append(-1)

maxcnt = 0
candi = [0, 0]
for l in range(n):
    for r in range(l, n):
        cnt = 0
        s[l], s[r] = s[r], s[l]
        ssum = [0]*n
        ssum[0] = s[0]
        for i in range(1, n):
            ssum[i] = ssum[i-1] + s[i]

        minssum = min(ssum)
        if ssum[n-1] != 0:
            continue

        for i in range(1, n):
            if ssum[i] == minssum:
                cnt += 1
        if maxcnt < cnt:
            candi = [r, l]
            maxcnt = cnt
        s[l], s[r] = s[r], s[l]
print(maxcnt)
print(candi[0]+1, candi[1]+1)