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 N = 1000005;
void solve() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  s = 'a' + s;
  s = s + 'a';
  pair<long long int, long long int> pre[n + 5], suf[n + 5];
  for (long long int i = 0; i < n + 5; i++)
    pre[i].first = suf[i].first = 0, pre[i].second = suf[i].second = 1;
  long long int chk = 1, open = 0, close = 0;
  for (long long int i = 1; i <= n; i++) {
    if (s[i] == '(')
      open++;
    else
      close++;
    long long int temp = open - close;
    if (temp < 0 && chk) chk = 0;
    pre[i].first = temp;
    pre[i].second = chk;
  }
  chk = 1, open = 0, close = 0;
  for (long long int i = n; i >= 1; i--) {
    if (s[i] == '(')
      open++;
    else
      close++;
    long long int temp = close - open;
    if (temp < 0 && chk) chk = 0;
    suf[i].first = temp;
    suf[i].second = chk;
  }
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    long long int c1 = pre[i - 1].second;
    long long int c2 = suf[i + 1].second;
    if (c1 & c2) {
      char now = s[i];
      if (now == '(')
        now = ')';
      else
        now = '(';
      if (now == '(') {
        long long int t1 = pre[i - 1].first;
        long long int t2 = suf[i + 1].first - 1;
        if (t1 == t2) ans++;
      } else {
        long long int t1 = suf[i + 1].first;
        long long int t2 = pre[i - 1].first - 1;
        if (t1 == t2) ans++;
      }
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}
