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 U, class T>
void Max(U &first, T second) {
  if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
  if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
  a = (a + b) % 998244353;
}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 998244353;
    a = 1LL * a * a % 998244353;
    b >>= 1;
  }
  return ans;
}
int pow(int a, int b, int c) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % c;
    a = 1LL * a * a % c;
    b >>= 1;
  }
  return ans;
}
int dp[3], ndp[3];
char s[200010 * 5];
int main() {
  int ca = 0, T, k, i, j, m = 0, n;
  double start = clock();
  scanf("%d%s", &n, s);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    k = (s[i] == '(' ? 1 : -1);
    for (int j = 0; j < 3; j++) ndp[j] = 0;
    if (dp[0]) {
      if (m + k >= 0) ndp[0] = dp[0];
      if (m - k >= 0) ndp[k < 0 ? 1 : 2] += dp[0];
    }
    if (dp[1]) {
      if (m + 2 + k >= 0) ndp[1] += dp[1];
    }
    if (dp[2]) {
      if (m - 2 + k >= 0) ndp[2] += dp[2];
    }
    m += k;
    swap(dp, ndp);
  }
  int ans = 0;
  if (m == 2 && dp[2])
    ans = dp[2];
  else if (m == -2 && dp[1])
    ans = dp[1];
  printf("%d\n", ans);
  cerr << (1. * clock() - start) / CLOCKS_PER_SEC << "\n";
}
