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 mod = 1e9 + 7;
const int N = 1e6 + 7;
pair<int, int> pref[N], suff[N];
int remL[N], remR[N];
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int c1 = 0, c2 = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == ')')
      c2++;
    else
      c1++;
  }
  if (s[0] == '(')
    pref[0].first = 1;
  else
    pref[0].second = 1;
  for (int i = 1; i < s.length(); ++i) {
    if (s[i] == ')') {
      pref[i].second = pref[i - 1].second + 1;
      pref[i].first = pref[i - 1].first;
    } else {
      pref[i].second = pref[i - 1].second;
      pref[i].first = pref[i - 1].first + 1;
    }
    if (pref[i].second > pref[i].first + 2) {
      cout << 0;
      return 0;
    }
  }
  remL[0] = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i - 1] == '(')
      remL[i] = remL[i - 1] + 1;
    else
      remL[i] = max(0, remL[i - 1] - 1);
  }
  remR[n - 1] = 0;
  for (int i = n - 2; i >= 0; --i) {
    if (s[i + 1] == ')')
      remR[i] = remR[i + 1] + 1;
    else
      remR[i] = max(0, remR[i + 1] - 1);
  }
  if (s[n - 1] == '(')
    suff[n - 1].first = 1;
  else
    suff[n - 1].second = 1;
  for (int i = s.length() - 2; i >= 0; --i) {
    if (s[i] == ')') {
      suff[i].second = suff[i + 1].second + 1;
      suff[i].first = suff[i + 1].first;
    } else {
      suff[i].second = suff[i + 1].second;
      suff[i].first = suff[i + 1].first + 1;
    }
    if (suff[i].first > suff[i].second + 2) {
      cout << 0;
      return 0;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i != 1 && s[0] == ')') {
      continue;
    }
    if (i != n && s[n - 1] == '(') {
      continue;
    }
    if (s[i - 1] == '(') {
      if (remL[i - 1] == 0) continue;
      if (remL[i - 1] == remR[i - 1] + 1) {
        ans++;
      }
    } else if (s[i - 1] == ')') {
      if (remR[i - 1] == 0) continue;
      if (remL[i - 1] + 1 == remR[i - 1]) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
