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;
const long double PI = acos(-1);
long long int Mod = 1000000007;
long long int power(long long int b, long long int e, long long int m) {
  long long int res = 1;
  while (e) {
    if (e & 1) {
      res = (res * (b % m)) % m;
      e--;
    } else {
      b = ((b % m) * (b % m)) % m;
      e = e / 2;
    }
  }
  return res;
}
long long int power(long long int b, long long int e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
bool isprime(long long int n) {
  if (n == 1) return 0;
  for (long long int i = 2; i < sqrt(n) + 2; i++) {
    if (n % i == 0 && (i != n)) {
      return 0;
    }
  }
  return 1;
}
void Its_time_to_go_in_loop() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int c = 0;
  vector<long long int> dp(n + 2, 1), lp(n + 2, 1), dp1(n + 2, 0),
      lp1(n + 2, 0);
  long long int x = 1;
  for (long long int i = 1; i < n + 1; i++) {
    if (s[i - 1] == '(') {
      c++;
    } else
      c--;
    dp1[i] = c;
    if (c <= -1 && x) {
      x = 0;
      for (long long int j = i; j < n + 1; j++) {
        dp[j] = 0;
      }
    }
  }
  c = 0;
  x = 1;
  for (long long int i = n; i > 0; i--) {
    if (s[i - 1] == ')') {
      c++;
    } else
      c--;
    lp1[i] = c;
    if (c <= -1 && x) {
      x = 0;
      for (long long int j = i; j > 0; j--) {
        lp[j] = 0;
      }
    }
  }
  long long int ans = 0;
  for (long long int i = 1; i < n + 1; i++) {
    if (s[i - 1] == '(') {
      if (i == 1) continue;
      if (!dp[i - 1] || (!lp[i + 1])) continue;
      if (((dp1[i - 1] - 1 == 0) && (lp1[i + 1] == 0)) ||
          (dp1[i - 1] > 0 && lp1[i + 1] > 0 &&
           ((dp1[i - 1] - 1 - lp1[i + 1]) == 0))) {
        ans++;
      }
    } else {
      if (i == n) continue;
      if (!dp[i - 1] || (!lp[i + 1])) continue;
      if (((dp1[i - 1] == 0) && (lp1[i + 1] - 1 == 0)) ||
          (dp1[i - 1] > 0 && lp1[i + 1] > 0 &&
           ((dp1[i - 1] + 1 - lp1[i + 1]) == 0))) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t = 1, test = 1;
  while (t--) {
    Its_time_to_go_in_loop();
  }
  return 0;
}
