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.Vector;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Stack;
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);
        EAlmostRegularBracketSequence solver = new EAlmostRegularBracketSequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class EAlmostRegularBracketSequence {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char c[] = in.next().toCharArray();
            int a[] = new int[n];
            int b[] = new int[n];
            Stack<Integer> s = new Stack<>();
            s.push(-1);
            s.push(-2);
            int ct = 0, min = (int) 1e9;
            for (int i = 0; i < n; i++) {
                if (c[i] == '(') {
                    ct++;
                    s.push(i);
                } else {
                    ct--;
                    if (s.isEmpty()) {
                        out.println(0);
                        return;
                    }
                    s.pop();
                }
                a[i] = ct;
                min = Math.min(ct, min);
            }
            //System.out.println(min+" "+ct);
            if (s.size() == 4) {
                s.pop();
                s.pop();
            }
            int ans = 0;
            b[n - 1] = a[n - 1];
            for (int i = n - 2; i >= 0; i--) {
                b[i] = Math.min(b[i + 1], a[i]);
            }
            if (ct == -2 && s.size() == 0) {
                for (int i = 0; i < n; i++) {
                    ans += c[i] == ')' ? 1 : 0;
                    if (a[i] < 0) break;
                }
                out.println(ans);
            } else if (ct == 2 && s.size() == 2 && s.peek() == -2) {
                for (int i = 1; i < n; i++) {
                    if (c[i] == '(' && b[i] == 2) {
                        ans++;
                    }
                }
                out.println(ans);
            } else {
                out.println(0);
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

