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.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();
            int[] bal = new int[n];
            for (int i = 0; i < n; i++) {
                bal[i] = (i > 0) ? bal[i - 1] : 0;
                if (s.charAt(i) == '(') {
                    bal[i]++;
                }
                if (s.charAt(i) == ')') {
                    bal[i]--;
                }
            }
            int minBalVal = 0;
            for (int i = 0; i < n; i++) {
                if (bal[i] < -2) {
                    out.println(0);
                    return;
                }
                minBalVal = Math.min(bal[i], minBalVal);
            }
            if (Math.abs(bal[n - 1]) != 2) {
                out.println(0);
                return;
            }
            if (bal[n - 1] == 2 && minBalVal < 0) {
                out.println(0);
                return;
            }
            int ans = 0;
            if (bal[n - 1] == 2) {
                int[] minBal = new int[n];
                minBal[n - 1] = bal[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    minBal[i] = Math.min(bal[i], minBal[i + 1]);
                }
                for (int i = 0; i < n; i++) {
                    if (s.charAt(i) == '(' && minBal[i] >= 2) {
                        ans++;
                    }
                }
            } else {
                int[] invBal = new int[n];
                for (int i = n - 1; i >= 0; i--) {
                    invBal[i] = (i < n - 1) ? invBal[i + 1] : 0;
                    if (s.charAt(i) == '(') {
                        invBal[i]--;
                    }
                    if (s.charAt(i) == ')') {
                        invBal[i]++;
                    }
                }
                int[] minBal = new int[n];
                minBal[0] = invBal[0];
                for (int i = 1; i < n; i++) {
                    minBal[i] = Math.min(invBal[i], minBal[i - 1]);
                }
                for (int i = n - 1; i >= 0; i--) {
                    if (s.charAt(i) == ')' && minBal[i] >= 2) {
                        ans++;
                    }
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

