#include <bits/stdc++.h>
using namespace std;
long long int inf = pow(10, 9) + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int ans = 0, n;
  cin >> n;
  string second;
  cin >> second;
  if (n & 1) return cout << 0, 0;
  vector<long long int> v(n), left(n), right(n);
  for (long long int i = 0; i < n; ++i) v[i] = (second[i] == '(') ? 1 : -1;
  right[0] = inf;
  for (long long int i = 1; i <= n - 1; ++i) {
    v[i] += v[i - 1];
    right[i] = min(v[i - 1], right[i - 1]);
  }
  left[n - 1] = inf;
  for (long long int i = n - 2; i >= 0; i--)
    left[i] = min(left[i + 1], v[i + 1]);
  for (long long int i = 0; i < n; ++i) {
    if (right[i] < 0) continue;
    if (second[i] == '(' and left[i] >= 2 and v[n - 1] == 2 and v[i] >= 2)
      ++ans;
    else if (second[i] == ')' and left[i] >= -2 and v[n - 1] == -2 and
             v[i] >= -2)
      ++ans;
  }
  cout << ans;
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

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;
long long int inf = pow(10, 9) + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int ans = 0, n;
  cin >> n;
  string second;
  cin >> second;
  if (n & 1) return cout << 0, 0;
  vector<long long int> v(n), left(n), right(n);
  for (long long int i = 0; i < n; ++i) v[i] = (second[i] == '(') ? 1 : -1;
  right[0] = inf;
  for (long long int i = 1; i <= n - 1; ++i) {
    v[i] += v[i - 1];
    right[i] = min(v[i - 1], right[i - 1]);
  }
  left[n - 1] = inf;
  for (long long int i = n - 2; i >= 0; i--)
    left[i] = min(left[i + 1], v[i + 1]);
  for (long long int i = 0; i < n; ++i) {
    if (right[i] < 0) continue;
    if (second[i] == '(' and left[i] >= 2 and v[n - 1] == 2 and v[i] >= 2)
      ++ans;
    else if (second[i] == ')' and left[i] >= -2 and v[n - 1] == -2 and
             v[i] >= -2)
      ++ans;
  }
  cout << ans;
  return 0;
}

```