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 int maxn = 1 * 1e6 + 55;
bool vis[maxn];
int n;
string s;
struct ans {
  int left, right;
};
ans st[maxn << 2];
ans config(ans a, ans b) {
  ans c;
  c.right = a.right;
  c.left = b.left;
  int mn = min(a.left, b.right);
  c.left += a.left - mn;
  c.right += b.right - mn;
  return c;
}
void build(int i, int l, int r) {
  int m = (l + r) >> 1;
  if (l == r) {
    s[l] == '(' ? (st[i].left = 1) : (st[i].right = 1);
    return;
  }
  int lc, rc;
  lc = i << 1;
  rc = (i << 1) | 1;
  build(lc, l, m);
  build(rc, m + 1, r);
  st[i] = config(st[lc], st[rc]);
}
void update(int x, int i, int l, int r) {
  if (l == r) {
    if (s[l] == '(')
      s[l] = ')';
    else
      s[l] = '(';
    st[i].left = st[i].right = 0;
    s[l] == '(' ? st[i].left = 1 : st[i].right = 1;
    return;
  }
  int m = (l + r) >> 1;
  int lc = i << 1, rc = (i << 1) | 1;
  if (x <= m)
    update(x, lc, l, m);
  else
    update(x, rc, m + 1, r);
  st[i] = config(st[lc], st[rc]);
}
ans query(int ql, int qr, int i, int l, int r) {
  if (ql <= l && qr >= r) return st[i];
  if (ql > r || qr < l) return ans();
  int m = (l + r) >> 1;
  int lc = i << 1, rc = (i << 1) | 1;
  return config(query(ql, qr, lc, l, m), query(ql, qr, rc, m + 1, r));
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  memset(vis, false, sizeof vis);
  cin >> n >> s;
  build(1, 0, n - 1);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    update(i, 1, 0, n - 1);
    ans += (st[1].left == 0 && st[1].right == 0);
    update(i, 1, 0, n - 1);
  }
  cout << ans;
}
