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;
int n, q;
string s;
int tip, st, dr;
struct aint {
  int sum;
  int minim, maxim;
  int lazy;
};
aint v[4000002];
void propagate(int nod, int st, int dr) {
  v[nod].sum *= -1;
  int aa = v[nod].maxim;
  int bb = v[nod].minim;
  v[nod].minim = aa * -1;
  v[nod].maxim = bb * -1;
  v[nod].lazy = 0;
  if (st != dr) {
    v[nod << 1].lazy ^= 1;
    v[nod << 1 | 1].lazy ^= 1;
  }
}
void build(int nod, int st, int dr) {
  if (st == dr) {
    if (s[st - 1] == '(')
      v[nod].sum = 1, v[nod].maxim = 1, v[nod].minim = 1;
    else
      v[nod].sum = -1, v[nod].maxim = -1, v[nod].minim = -1;
    return;
  }
  int mid = (st + dr) / 2;
  build(nod << 1, st, mid);
  build(nod << 1 | 1, mid + 1, dr);
  v[nod].sum = v[nod << 1].sum + v[nod << 1 | 1].sum;
  v[nod].maxim =
      max(v[nod << 1].maxim, v[nod << 1].sum + v[nod << 1 | 1].maxim);
  v[nod].minim =
      min(v[nod << 1].minim, v[nod << 1].sum + v[nod << 1 | 1].minim);
}
void update(int nod, int st, int dr, int L, int R) {
  if (v[nod].lazy) propagate(nod, st, dr);
  if (R < st || dr < L) return;
  if (L <= st && dr <= R) {
    propagate(nod, st, dr);
    return;
  }
  int mid = (st + dr) / 2;
  update(nod << 1, st, mid, L, R);
  update(nod << 1 | 1, mid + 1, dr, L, R);
  v[nod].sum = v[nod << 1].sum + v[nod << 1 | 1].sum;
  v[nod].maxim =
      max(v[nod << 1].maxim, v[nod << 1].sum + v[nod << 1 | 1].maxim);
  v[nod].minim =
      min(v[nod << 1].minim, v[nod << 1].sum + v[nod << 1 | 1].minim);
}
int summ = 0, mini = 10000000;
void query(int nod, int st, int dr, int L, int R) {
  if (v[nod].lazy) propagate(nod, st, dr);
  if (R < st || dr < L) return;
  if (L <= st && dr <= R) {
    mini = min(mini, summ + v[nod].minim);
    summ += v[nod].sum;
    return;
  }
  int mid = (st + dr) / 2;
  query(nod << 1, st, mid, L, R);
  query(nod << 1 | 1, mid + 1, dr, L, R);
  v[nod].sum = v[nod << 1].sum + v[nod << 1 | 1].sum;
  v[nod].maxim =
      max(v[nod << 1].maxim, v[nod << 1].sum + v[nod << 1 | 1].maxim);
  v[nod].minim =
      min(v[nod << 1].minim, v[nod << 1].sum + v[nod << 1 | 1].minim);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  cin >> s;
  build(1, 1, n);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    update(1, 1, n, i, i);
    summ = 0;
    mini = 10000000;
    if (n % 2 == 1) continue;
    query(1, 1, n, 1, n);
    if (mini == 0 && summ == 0) ++ans;
    update(1, 1, n, i, i);
  }
  cout << ans;
  return 0;
}
