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 n, i, j, k, l, m, s1[101010], s2[101010], f[201], x, y, u, v,
    lx[4 * 1010101], rx[4 * 1010101];
map<long long, long long> q;
string s;
const int MAXN = 201010;
void push(long long x, long long lm, long long rm) {
  if (lx[lm] >= rx[rm]) {
    lx[x] = lx[lm] - rx[rm] + lx[rm];
    rx[x] = rx[lm];
  } else {
    rx[x] = rx[rm] - lx[lm] + rx[lm];
    lx[x] = lx[rm];
  }
}
void build(long long x, long long l, long long r) {
  if (l == r) {
    if (s[l - 1] == '(') {
      lx[x] = 1;
    } else {
      rx[x] = 1;
    }
    return;
  }
  long long m = (l + r) >> 1, lm = x * 2, rm = x * 2 + 1;
  build(lm, l, m);
  build(rm, m + 1, r);
  push(x, lm, rm);
}
void up(long long p, long long l, long long r, long long k) {
  if (l == r) {
    lx[p] = !lx[p];
    rx[p] = !rx[p];
    return;
  }
  long long m = (l + r) >> 1, lm = p * 2, rm = p * 2 + 1;
  if (k <= m)
    up(lm, l, m, k);
  else {
    up(rm, m + 1, r, k);
  }
  push(p, lm, rm);
}
long long ans = 0;
int main() {
  cin >> n;
  cin >> s;
  build(1, 1, n);
  for (i = 1; i <= n; i++) {
    up(1, 1, n, i);
    if (lx[1] == 0 && rx[1] == 0) {
      ans++;
    }
    up(1, 1, n, i);
  }
  cout << ans;
}
