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
//package que_c;

import java.io.*;
import java.util.*;

public class utkarsh {
    
    BufferedReader br;
    PrintWriter out;
    
    long mod = (long) (1e9 + 7), inf = (long) (3e18);
    
    void solve() {
        int n = ni();
        char s[] = ns().toCharArray();
        int op = 0, cl = 0, x = 0, m = 0;
        for(char c : s) {
            if(c == '(') {
                op++;   x++;
            } else {
                cl++;   x--;
            }
            m = Math.min(m, x);
        }
        if(Math.abs(op - cl) != 2)  out.println(0);
        else if(op > cl && m == 0) {
            int ans = 0;    x = 0;
            for(int c : s) {
                if(c == '(') {
                    if(x > 0)   ans++;
                    x++;
                } else  x--;
                if(x < 2)  ans = 0;
            }
            out.println(ans);
        } else if(cl > op && m == -2) {
            int ans = 0;    x = 0;
            for(int c : s) {
                if(c == ')') {
                    ans++;
                    x--;
                } else  x++;
                if(x < 0)   break;
            }
            out.println(ans);
        } else  out.println(0);
    }
    
    char[] input(int n) {
        char s[] = new char[n];
        for(int i = 0; i < n; i++) {
            if(Math.random() < 0.5) s[i] = '(';
            else    s[i] = ')';
        }
        return s;
    }
    
    long mp(long b, long e) {
        long r = 1;
        while(e > 0) {
            if( (e&1) == 1 )    r = (r * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return r;
    }
    
    // -------- I/O Template -------------
    
    char nc() {
        return ns().charAt(0);
    }
    
    String nLine() {
        try {
            return br.readLine();
        } catch(IOException e) {
            return "-1";
        }
    }
    
    double nd() {
        return Double.parseDouble(ns());
    }
    
    long nl() {
        return Long.parseLong(ns());
    }
    
    int ni() {
        return Integer.parseInt(ns());
    }
    
    StringTokenizer ip;
    
    String ns() {
        if(ip == null || !ip.hasMoreTokens()) {
            try {
                ip = new StringTokenizer(br.readLine());
            } catch(IOException e) {
                throw new InputMismatchException();
            }
        }
        return ip.nextToken();
    }
    
    void run() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }
    
    public static void main(String[] args) {
        new utkarsh().run();
    }
}