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

public class Problem529E {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader();
		int n=s.nextInt();
		String string=s.next();
		int[] prefixsum=new int[string.length()];
		prefixsum[0]=0;
		boolean[] prefixcheck=new boolean[string.length()];
		prefixcheck[0]=true;
		for(int i=1;i<string.length();i++) {
			prefixsum[i]+=prefixsum[i-1]+(string.charAt(i-1)==')'?-1:1);
			prefixcheck[i]=prefixcheck[i-1] & prefixsum[i]>=0; 
		}
		int[] suffixsum=new int[string.length()];
		suffixsum[n-1]=0;
		boolean[] suffixcheck=new boolean[string.length()];
		suffixcheck[n-1]=true;
		for(int i=n-2;i>=0;i--) {
			suffixsum[i]=suffixsum[i+1]+(string.charAt(i+1)==')'?-1:1);
			suffixcheck[i]=suffixcheck[i+1]&(suffixsum[i]<=0);
		}
		int ans=0;
		for(int i=0;i<n;i++){
			if(suffixsum[i]<=0 && prefixsum[i]>=0) {
				if(!suffixcheck[i] || !prefixcheck[i]) {
					continue;
				}
				int sum=-suffixsum[i]-prefixsum[i];
				if(sum==-1) {
					if(string.charAt(i)=='(') {
						ans++;
					}
				}else if(sum==1){
					if(string.charAt(i)==')') {
						ans++;
					}
				}
			}
		}
		out.println(ans);
		out.close();
	}

	public static void No() {
		out.println(0);
		out.close();
		System.exit(0);
	}
	
	public static boolean Checker(int[] arr) {
		int sum=0;
		for(int i=0;i<arr.length;i++) {
			sum+=arr[i];
			if(sum==-1)return false;
		}
		if(sum==0) return true;
		return false;
	}
	
	public static PrintWriter out;
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

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

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

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
}
