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
import java.util.*;
import java.io.*;
public class Solution implements Runnable{
    FastScanner sc;
    PrintWriter pw;
    final class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
 
        public long nlo() {
            return Long.parseLong(next());
        }
 
        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }
 
        public int ni() {
            return Integer.parseInt(next());
        }
 
        public String nli() {
            String line = "";
            if (st.hasMoreTokens()) line = st.nextToken();
            else try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            while (st.hasMoreTokens()) line += " " + st.nextToken();
            return line;
        }
 
        public double nd() {
            return Double.parseDouble(next());
        }
    }
    public static void main(String[] args) throws Exception
    {
        new Thread(null,new Solution(),"codeforces",1<<28).start();
    }
    public void run()
    {
        sc=new FastScanner();
        pw=new PrintWriter(System.out);
        solve();
        pw.flush();
        pw.close();
    }
    public long gcd(long a,long b)
    {
        return b==0L?a:gcd(b,a%b);
    }
    public long ppow(long a,long b,long mod)
    {
        if(b==0L)
        return 1L;
        long tmp=1;
        while(b>1L)
        {
            if((b&1L)==1)
            tmp*=a;
            a*=a;
            a%=mod;
            tmp%=mod;
            b>>=1;
        }
        return (tmp*a)%mod;
    }
    public  int gcd(int x,int y)
    {
        return y==0?x:gcd(y,x%y);
    }
    //////////////////////////////////
    /////////////  LOGIC  ///////////
    ////////////////////////////////
  public void solve()
  {
      int n=sc.ni();
      String str=sc.next();
      char[] arr=str.toCharArray();
    if(n%2==1)
    {
        pw.println(0);
        return;
    }
    else
    {
        int[] prr=new int[n];
        Arrays.fill(prr,-1);
        int[] srr=new int[n];
        Arrays.fill(srr,-1);
        int p=0;
        for(int i=0;i<n;i++)
        {
            if(arr[i]=='(')
            p++;
            else
            p--;
            if(p>=0)
            prr[i]=p;
            else
            break;
        }
        p=0;
        for(int i=n-1;i>=0;i--)
        {
            if(arr[i]==')')
            p++;
            else
            p--;
            if(p>=0)
            srr[i]=p;
            else
            break;
        }
        int ans=0;
        for(int i=0;i<n;i++)
        {
            if(i==0)
                {if((arr[i]==')')&&(srr[i+1]==1))
                    ans++;}
            else if(i==n-1)
                {if((arr[n-1]=='(')&&(prr[n-2]==1))
                    ans++;}
            else
            {
                if(arr[i]==')')
                    {if(srr[i+1]>0&&prr[i-1]>=0&&(prr[i-1]==(srr[i+1]-1)))
                    ans++;}
                else
                    {if(prr[i-1]>0&&srr[i+1]>=0&&(srr[i+1]==(prr[i-1]-1)))
                    ans++;}
            }
        }
        pw.println(ans);
    }
    }
}