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.*;
import java.util.*;

import static java.lang.Math.*;
import static java.lang.System.*;

public class Solver {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        String s = in.next();
        int pref[] = new int[n];
        int suf[] = new int[n];
        int min_pref[] = new int[n];
        boolean oks[] = new boolean[n];
        int cnt = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '(') ++cnt;
            else --cnt;
            pref[i] = cnt;
            if (i == 0) min_pref[i] = cnt;
            else min_pref[i] = min(cnt, min_pref[i - 1]);
        }
        cnt = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == '(') --cnt;
            else ++cnt;
            suf[i] = cnt;
            oks[i] = cnt >= 0;
            if (i != n - 1) oks[i] &= oks[i + 1];
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '(') {
                int prefix = i == 0 ? 0 : pref[i - 1];
                int suffix = i == n - 1 ? 0 : suf[i + 1];
                int minpr = i == 0 ? 0 : min_pref[i-1];
                boolean can = prefix - suffix - 1 == 0;
                can&=minpr>=0;
                can&=(i == n - 1 || oks[i+1]);
                if(can)++ans;
            }else{
                int prefix = i == 0 ? 0 : pref[i - 1];
                int suffix = i == n - 1 ? 0 : suf[i + 1];
                int minpr = i == 0 ? 0 : min_pref[i-1];
                boolean can = prefix - suffix + 1 == 0;
                can&=minpr>=0;
                can&=(i == n - 1 || oks[i+1]);
                if(can)++ans;
            }
        }
        out.println(ans);
        out.close();
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    FastScanner(String s) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(s));
    }

    FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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