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 = 1e6 + 6;
const int K = 50;
const long long mod = 1e9 + 7;
int n, k, w, m, u, v, l, r;
int diff[N] = {0};
void solve(string &s) {
  int pos = 0;
  memset(diff, 0, sizeof diff);
  for (int i = 1; i <= n; i++) {
    diff[i] = diff[i - 1];
    if (s[i - 1] == '(')
      diff[i]++;
    else
      diff[i]--;
  }
  for (int i = n; i >= 1; i--) {
    if (diff[i] == 1) {
      pos = i;
      break;
    }
  }
  int ans = 0;
  for (int i = pos; i < n; i++) {
    if (s[i] == '(') ans++;
  }
  cout << ans << '\n';
}
int countMinReversals(string expr) {
  int len = expr.length();
  if (len % 2) return -1;
  stack<char> s;
  for (int i = 0; i < len; i++) {
    if (expr[i] == ')' && !s.empty()) {
      if (s.top() == '(')
        s.pop();
      else
        s.push(expr[i]);
    } else
      s.push(expr[i]);
  }
  int red_len = s.size();
  int n = 0;
  while (!s.empty() && s.top() == '(') {
    s.pop();
    n++;
  }
  return (red_len / 2 + n % 2);
}
int main() {
  cin >> n;
  string s;
  cin >> s;
  int ct = countMinReversals(s);
  if (ct != 1) {
    cout << "0\n";
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    diff[i] = diff[i - 1];
    if (s[i - 1] == '(')
      diff[i]++;
    else
      diff[i]--;
  }
  if (diff[n] != 2 && diff[n] != -2)
    cout << "0\n";
  else {
    if (diff[n] == 2)
      solve(s);
    else {
      reverse(s.begin(), s.end());
      for (char &c : s) {
        if (c == '(')
          c = ')';
        else
          c = '(';
      }
      solve(s);
    }
  }
  return 0;
}
