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;
template <class T>
bool uin(T& a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T& a, T b) {
  return a < b ? (a = b, true) : false;
}
const int INF = 1e9;
void impossible() {
  cout << 0 << '\n';
  exit(0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n % 2) impossible();
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += (s[i] == '(' ? 1 : -1);
  }
  if (abs(cnt) != 2) impossible();
  char positive;
  if (cnt == 2)
    positive = '(';
  else
    positive = ')';
  vector<int> pref(n);
  for (int i = 0; i < n; ++i) {
    pref[i] = (s[i] == '(' ? 1 : -1) + (i ? pref[i - 1] : 0);
  }
  vector<int> tree(n + n);
  for (int i = 0; i < n; ++i) tree[i + n] = pref[i];
  for (int i = n - 1; i > 0; --i) tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
  auto query = [&](int l, int r) {
    int res = INF;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) uin(res, tree[l++]);
      if (r & 1) uin(res, tree[--r]);
    }
    return res;
  };
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (positive == '(') {
      if (s[i] == positive && pref[i] >= 2 && query(0, i) >= 0 &&
          query(i + 1, n) >= 2)
        ++ans;
    } else if (positive == ')') {
      if (s[i] == positive && query(0, i) >= 0 && query(i + 1, n) >= -2) ++ans;
    }
  }
  cout << ans << '\n';
}
