You are given a bracket sequence s consisting of n opening '(' and closing ')' brackets.

A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For example, bracket sequences "()()", "(())" are regular (the resulting expressions are: "(1)+(1)", "((1+1)+1)"), and ")(" and "(" are not.

You can change the type of some bracket s_i. It means that if s_i =  ')' then you can change it to '(' and vice versa.

Your task is to calculate the number of positions i such that if you change the type of the i-th bracket, then the resulting bracket sequence becomes regular.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 10^6) — the length of the bracket sequence.

The second line of the input contains the string s consisting of n opening '(' and closing ')' brackets.

Output

Print one integer — the number of positions i such that if you change the type of the i-th bracket, then the resulting bracket sequence becomes regular.

Examples

Input


6
(((())


Output


3


Input


6
()()()


Output


0


Input


1
)


Output


0


Input


8
)))(((((


Output


0
# https://codeforces.com/contest/1095/problem/E

n = int(input())
s = input()#'(()))())'

pre=[]
suf=[]

for i, x in enumerate(s):
    if len(pre)==0:
        pre.append([1, 0] if x=='(' else [0, 1])
    else:
        pre1, pre2 = pre[-1]
        cur1, cur2 = None, None
        
        if x=='(':
            cur1, cur2 = pre1+1, pre2
        else:
            if pre1 > 0:
                cur1, cur2 = pre1-1, pre2
            else:
                cur1, cur2 = pre1, pre2 + 1
        pre.append([cur1, cur2])
        
for i, x in enumerate(s[::-1]):
    if len(suf)==0:
        suf.append([0, 1] if x==')' else [1, 0])
    else:
        pre1, pre2 = suf[-1]
        cur1, cur2 = None, None
        if x==')':
            cur1, cur2 = pre1, pre2+1
        else:
            if pre2 > 0:
                cur1, cur2 = pre1, pre2 - 1
            else:
                cur1, cur2 = pre1+1, pre2
        suf.append([cur1, cur2])       
        
suf = suf[::-1]        

ans=0
for i, x in enumerate(s):
    pre1, pre2, suf1, suf2 = 0, 0, 0, 0    
    
    if i>0:
        pre1, pre2 = pre[i-1]
    if i+1<n:
        suf1, suf2 = suf[i+1]
        
    if x == ')':
        pre1+=1
    else:
        if pre1>0:
            pre1-=1
        else:    
            pre2+=1
        
    if pre2==0 and suf1==0 and pre1==suf2:
        #print(i)
        ans+=1
print(ans)        