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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Solution{
	
	static final int maxn = (int)1e6+10;
	
	
	
    public static void main(String[] args) throws IOException {
     
    	FastScanner fs = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);
    	
    		
    		
    	int tt = 1;
    	while(tt-->0) {
    		
    		int n = fs.nextInt();
    		
    		String s = fs.next();
    		
    		char[] ch = new char[n+1];
    		for(int i=1;i<=n;i++) {
    			ch[i] = s.charAt(i-1);
    		}
    		
    		int[] prefBal = new int[maxn], sufBal = new int[maxn];
    		boolean[] prefCan = new boolean[maxn], sufCan = new boolean[maxn];
    		Arrays.fill(prefCan, true); Arrays.fill(sufCan, true);
    		
    		
    		for(int i=1;i<=n;i++) {
    			prefBal[i] = prefBal[i-1] + ((ch[i]=='(')?1:-1);
    			prefCan[i] = prefCan[i-1]&(prefBal[i]>=0);
    		}
    		
    		for(int i=n;i>0;i--) {
    			sufBal[i] = sufBal[i+1] + ((ch[i]==')')?1:-1);
    			sufCan[i] = sufCan[i+1]&(sufBal[i]>=0);
    		}
    		
    		int ans = 0;
    		
    		for(int i=1;i<=n;i++) {
    			if(!(prefCan[i-1]&sufCan[i+1])) continue;
    			if(ch[i]=='(') {
    				if(prefBal[i-1]-1-sufBal[i+1]==0) ans++;
    			}
    			else {
    				if(prefBal[i-1]+1-sufBal[i+1]==0) ans++;
    			}
    		}
    		
    		out.println(ans);
    		
    		
    		
    		
    	}
    	
    		
    		
    		
    	out.close();
    		
    }
    
    
 
    
    
    
    
    
    
    
    
    
    
    
    static final Random random=new Random();
    	
    static void ruffleSort(int[] a) {
    	int n=a.length;//shuffle, then sort 
    	for (int i=0; i<n; i++) {
    		int oi=random.nextInt(n); int temp=a[oi];
    		a[oi]=a[i]; a[i]=temp;
    	}
    	Arrays.sort(a);
    }
   
  
    
    	
    	
    static class FastScanner{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
     
    	public String next(){
    		while(!st.hasMoreElements()){
    			try{
    				st = new StringTokenizer(br.readLine());
    			} catch(IOException e){
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}
    		
    	public String nextLine() throws IOException {
    		return br.readLine();
    	}
    		
    	public int nextInt(){
    		return Integer.parseInt(next());
    	}
     
    	public int[] readArray(int n){
    		int[] a = new int[n];
    		for(int i=0;i<n;i++)
    			a[i] = nextInt();
    		return a;
    	}
    		
    	public long nextLong() {
    		return Long.parseLong(next());
    	}
    		
    	public char nextChar() {
    		return next().toCharArray()[0];
    	}
    }
   	
}
