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 Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().run(in, out);
        out.close();
    }

    public static long mod = 17352642619633L;

    void run(FastScanner in, PrintWriter out) {

        int N = in.nextInt();
        char[] ca = in.next().toCharArray();


        int[] bal = new int[N+2];
        int[] rbal = new int[N+2];
        boolean[] good = new boolean[N+2];
        boolean[] rgood = new boolean[N+2];

        good[0] = true;
        rgood[N+1] = true;

        int b = 0;
        for (int i = 0; i < N; i++) {
            if (ca[i] == '(') b++;
            else b--;
            bal[i+1] = b;
            good[i+1] = good[i] && b >= 0;
        }

        b = 0;
        for (int i = N-1; i >= 0; i--) {
            if (ca[i] == ')') b++;
            else b--;
            rbal[i+1] = b;
            rgood[i+1] = rgood[i+2] && b >= 0;
        }

        int cnt = 0;
        for (int i = 0; i < N; i++) {

            if (!good[i] || !rgood[i+2]) continue;

            // change current
            if (ca[i] == '(') {
                // change from open to closed
                if (bal[i]-1-rbal[i+2] == 0) cnt++;
            } else {
                // change from closed to open
                if (bal[i] + 1 - rbal[i+2] == 0) cnt++;
            }
        }

        out.println(cnt);

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}
