#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e9 + 5;
const double eps = 1e-7;
const double PI = acos(-1.0);
inline void debug_vi(vector<int> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void debug_vll(vector<long long> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void print_case(int tn) { cout << "Case #" << tn << ": "; }
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxpq = priority_queue<T>;
const int N = 1e6 + 5;
int unbalance[N];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t clk = clock();
  int n;
  cin >> n;
  string s;
  cin >> s;
  int a = 0, b = 0;
  for (char c : s) {
    if (c == '(')
      a++;
    else
      b++;
  }
  int res = 0;
  if (n % 2 == 0 && abs(a - b) == 2) {
    int unbal = 0;
    if (a > b) {
      for (long long i = (long long)(n - 1); i >= (long long)(0); i--) {
        if (s[i] == ')')
          unbal++;
        else
          unbal--;
        if (unbal <= -3) {
          cout << 0 << "\n";
          return 0;
        }
        unbalance[i] = unbal;
      }
      for (long long i = (long long)(n - 1); i >= (long long)(0); i--) {
        if (s[i] == '(') res++;
        if (unbalance[i] < 0) break;
      }
    } else {
      for (long long i = (long long)(0); i < (long long)(n); i++) {
        if (s[i] == '(')
          unbal++;
        else
          unbal--;
        if (unbal <= -3) {
          cout << 0 << "\n";
          return 0;
        }
        unbalance[i] = unbal;
      }
      for (long long i = (long long)(0); i < (long long)(n); i++) {
        if (s[i] == ')') res++;
        if (unbalance[i] < 0) break;
      }
    }
  }
  cout << res;
  cerr << "\n"
       << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC
       << "\n";
  return 0;
}

### Prompt

Your task is to create a cpp solution to the following problem:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e9 + 5;
const double eps = 1e-7;
const double PI = acos(-1.0);
inline void debug_vi(vector<int> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void debug_vll(vector<long long> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void print_case(int tn) { cout << "Case #" << tn << ": "; }
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxpq = priority_queue<T>;
const int N = 1e6 + 5;
int unbalance[N];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t clk = clock();
  int n;
  cin >> n;
  string s;
  cin >> s;
  int a = 0, b = 0;
  for (char c : s) {
    if (c == '(')
      a++;
    else
      b++;
  }
  int res = 0;
  if (n % 2 == 0 && abs(a - b) == 2) {
    int unbal = 0;
    if (a > b) {
      for (long long i = (long long)(n - 1); i >= (long long)(0); i--) {
        if (s[i] == ')')
          unbal++;
        else
          unbal--;
        if (unbal <= -3) {
          cout << 0 << "\n";
          return 0;
        }
        unbalance[i] = unbal;
      }
      for (long long i = (long long)(n - 1); i >= (long long)(0); i--) {
        if (s[i] == '(') res++;
        if (unbalance[i] < 0) break;
      }
    } else {
      for (long long i = (long long)(0); i < (long long)(n); i++) {
        if (s[i] == '(')
          unbal++;
        else
          unbal--;
        if (unbal <= -3) {
          cout << 0 << "\n";
          return 0;
        }
        unbalance[i] = unbal;
      }
      for (long long i = (long long)(0); i < (long long)(n); i++) {
        if (s[i] == ')') res++;
        if (unbalance[i] < 0) break;
      }
    }
  }
  cout << res;
  cerr << "\n"
       << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC
       << "\n";
  return 0;
}

```