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>
inline T gcd(T a, T b) {
  return (b) == 0 ? (a) : gcd((b), ((a) % (b)));
}
template <class T>
inline T lcm(T a, T b) {
  return ((a) / gcd((a), (b)) * (b));
}
template <class T>
inline T BigMod(T Base, T power, T M = 1000000007) {
  if (power == 0) return 1;
  if (power & 1)
    return ((Base % M) * (BigMod(Base, power - 1, M) % M)) % M;
  else {
    T y = BigMod(Base, power / 2, M) % M;
    return (y * y) % M;
  }
}
template <class T>
inline T ModInv(T A, T M = 1000000007) {
  return BigMod(A, M - 2, M);
}
int fx[] = {-1, +0, +1, +0, +1, +1, -1, -1, +0};
int fy[] = {+0, -1, +0, +1, +1, -1, +1, -1, +0};
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n;
string s;
int open[2000050], close[2000050];
int tree[4 * 2000050];
void Build(int node, int b, int e) {
  if (b == e) {
    tree[node] = open[b] - close[b];
    return;
  }
  int mid = (b + e) >> 1;
  int left = 2 * node;
  int right = left + 1;
  Build(left, b, mid);
  Build(right, mid + 1, e);
  tree[node] = min(tree[left], tree[right]);
}
int query(int node, int b, int e, int l, int r) {
  if (b > r || l > e) return INT_MAX / 10;
  if (b >= l && e <= r) return tree[node];
  int mid = (b + e) >> 1;
  int left = 2 * node;
  int right = left + 1;
  int p1 = query(left, b, mid, l, r);
  int p2 = query(right, mid + 1, e, l, r);
  return min(p1, p2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == '(')
      open[i]++;
    else
      close[i]++;
    open[i] += open[i - 1];
    close[i] += close[i - 1];
  }
  Build(1, 1, n);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == '(') {
      int x = query(1, 1, n, 1, i - 1);
      int y = query(1, 1, n, i, n);
      if (x >= 0 && y >= 2 && open[n] - close[n] == 2) ans++;
    } else {
      int x = query(1, 1, n, 1, i - 1);
      int y = query(1, 1, n, i, n);
      if (x >= 0 && y >= -2 && open[n] - close[n] == -2) ans++;
    }
  }
  cout << ans;
  return 0;
}
