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
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0 || b == 0) return 0;
  if (a == b) return a;
  if (a > b) return gcd(a % b, b);
  return gcd(a, b % a);
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int min(long long int a, long long int b) {
  if (a > b) return b;
  return a;
}
int main() {
  ios_base::sync_with_stdio;
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  if (n & 1) {
    cout << "0\n";
    return 0;
  }
  long long int pre[n], suf[n], canbepre[n], canbesuf[n];
  memset(pre, 0, sizeof(pre));
  memset(suf, 0, sizeof(suf));
  memset(canbepre, 0, sizeof(canbepre));
  memset(canbesuf, 0, sizeof(canbesuf));
  pre[0] = (s[0] == '(') - (s[0] == ')');
  if (pre[0] < 0)
    canbepre[0] = false;
  else
    canbepre[0] = true;
  for (long long int i = 1; i < n; i++)
    pre[i] = pre[i - 1] + (s[i] == '(') - (s[i] == ')'),
    canbepre[i] = canbepre[i - 1] && (pre[i] >= 0);
  suf[n - 1] = (s[n - 1] == ')') - (s[n - 1] == '(');
  if (suf[n - 1] < 0)
    canbesuf[n - 1] = false;
  else
    canbesuf[n - 1] = true;
  for (long long int i = n - 2; i >= 0; i--)
    suf[i] = suf[i + 1] + (s[i] == ')') - (s[i] == '('),
    canbesuf[i] = canbesuf[i + 1] && (suf[i] >= 0);
  long long int answer = 0;
  for (long long int i = 1; i < n - 1; i++) {
    if (pre[i - 1] - (s[i] == '(') + (s[i] == ')') != suf[i + 1]) continue;
    if (canbepre[i - 1] && canbesuf[i + 1]) answer++;
  }
  if (s[0] == ')') {
    if (canbesuf[1] && suf[1] == 1) answer++;
  }
  if (s[n - 1] == '(') {
    if (canbepre[n - 2] && pre[n - 2] == 1) answer++;
  }
  cout << answer << '\n';
  int dont_hack_please;
  return 0;
}
