#include <bits/stdc++.h>
using namespace std;
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const long long &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.first);
  putchar(' ');
  _W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
int MOD = 1e9 + 7;
void ADD(long long &x, long long v) {
  x = (x + v) % MOD;
  if (x < 0) x += MOD;
}
const int SIZE = 1e6 + 10;
char s[SIZE];
int AA[SIZE];
int main() {
  int n;
  R(n);
  if (n & 1)
    W(0);
  else {
    scanf("%s", (s + 1));
    int now = 0;
    for (int i = (1); i <= (n); ++i) {
      if (s[i] == '(')
        now++;
      else
        now--;
    }
    if (abs(now) != 2)
      W(0);
    else {
      if (now < 0) {
        for (int i = 1; i < n + 1 - i; i++) {
          swap(s[i], s[n + 1 - i]);
        }
        for (int i = (1); i <= (n); ++i) {
          if (s[i] == '(')
            s[i] = ')';
          else
            s[i] = '(';
        }
      }
      for (int i = (1); i <= (n); ++i) {
        AA[i] = AA[i - 1];
        if (s[i] == '(')
          AA[i]++;
        else
          AA[i]--;
        if (AA[i] < 0) {
          W(0);
          return 0;
        }
      }
      int mi = 2;
      int an = 0;
      for (int i = n; i > 0; i--) {
        mi = min(mi, AA[i]);
        if (mi >= 2 && s[i] == '(') an++;
      }
      W(an);
    }
  }
  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;
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const long long &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.first);
  putchar(' ');
  _W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
int MOD = 1e9 + 7;
void ADD(long long &x, long long v) {
  x = (x + v) % MOD;
  if (x < 0) x += MOD;
}
const int SIZE = 1e6 + 10;
char s[SIZE];
int AA[SIZE];
int main() {
  int n;
  R(n);
  if (n & 1)
    W(0);
  else {
    scanf("%s", (s + 1));
    int now = 0;
    for (int i = (1); i <= (n); ++i) {
      if (s[i] == '(')
        now++;
      else
        now--;
    }
    if (abs(now) != 2)
      W(0);
    else {
      if (now < 0) {
        for (int i = 1; i < n + 1 - i; i++) {
          swap(s[i], s[n + 1 - i]);
        }
        for (int i = (1); i <= (n); ++i) {
          if (s[i] == '(')
            s[i] = ')';
          else
            s[i] = '(';
        }
      }
      for (int i = (1); i <= (n); ++i) {
        AA[i] = AA[i - 1];
        if (s[i] == '(')
          AA[i]++;
        else
          AA[i]--;
        if (AA[i] < 0) {
          W(0);
          return 0;
        }
      }
      int mi = 2;
      int an = 0;
      for (int i = n; i > 0; i--) {
        mi = min(mi, AA[i]);
        if (mi >= 2 && s[i] == '(') an++;
      }
      W(an);
    }
  }
  return 0;
}

```