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 MOD = 1000000007;
const int N = 1000005;
const double PI = 4 * atan(1);
const long long MAX = 9223372036854775807;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
bool issquare(long long w) { return trunc(sqrt(w)) * trunc(sqrt(w)) == w; }
bool isprime(long long u) {
  for (long long i = 2; i <= (int)sqrt(u); i++) {
    if (u % i == 0) return 0;
  }
  return 1;
}
long long mod(long long to_mod, long long MOD) {
  to_mod %= MOD;
  while (to_mod < 0) to_mod += MOD;
  return to_mod % MOD;
}
long long moduloMultiplication(long long a, long long b) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a);
    a = (2 * a);
    b >>= 1;
  }
  return res;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long q, y, k, z, w, t, l, r, x, n, m, ans;
long long d[1000005];
long long u[1000005];
string ch;
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cin >> ch;
  u[0] = 0;
  d[n + 1] = 0;
  x = 0;
  y = 0;
  for (int i = 1; i <= n; i++) {
    if (ch[i - 1] == ')') {
      x--;
    } else if (x >= 0) {
      x++;
    }
    u[i] = x;
  }
  x = 0;
  y = 0;
  for (int i = n; i >= 1; i--) {
    if (ch[i - 1] == '(') {
      x--;
    } else if (x >= 0) {
      x++;
    }
    d[i] = x;
  }
  ans = 0;
  for (int i = 1; i <= n; i++) {
    if (u[i - 1] < 0 || d[i + 1] < 0) continue;
    if (ch[i - 1] == ')') {
      if (u[i - 1] + 1 == d[i + 1]) ans++;
    } else {
      if (u[i - 1] == d[i + 1] + 1) ans++;
    }
  }
  cout << ans;
  return 0;
}
