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;
vector<vector<long long> > v;
const int maxn = 4e6;
int vis[maxn];
int a[maxn];
const int mod = 998244353;
int n;
int s1[maxn];
int s2[maxn];
string str;
int Min1[maxn], Min2[maxn];
int Min3[maxn], Min4[maxn];
int check1(int i) {
  if (Min1[i] >= 0) return true;
  return false;
}
int len;
int check2(int i) {
  if (Min3[i] >= 2) return true;
  return false;
}
int check3(int i) {
  if (Min1[i] >= 0) return true;
  return false;
}
int check4(int i) {
  if (Min3[i] <= -2) return true;
  return false;
}
int main() {
  while (cin >> n) {
    memset(s1, 0, sizeof(s1));
    memset(s2, 0, sizeof(s2));
    memset(Min1, 0, sizeof(Min1));
    memset(Min2, 0, sizeof(Min2));
    cin >> str;
    len = str.size();
    int num1 = 0, num2 = 0;
    s1[-1] = 0;
    for (int i = 0; i < len; i++)
      if (str[i] == '(')
        s1[i] = s1[i - 1] + 1;
      else
        s1[i] = s1[i - 1] - 1;
    if (str[0] == '(')
      Min1[0] = 1;
    else
      Min1[0] = -1;
    for (int i = 1; i < len; i++) {
      Min1[i] = min(Min1[i - 1], s1[i]);
    }
    Min3[len] = 1e9;
    Min4[len] = 1e9;
    for (int i = len - 1; i >= 0; i--) {
      Min3[i] = min(Min3[i + 1], s1[i]);
    }
    for (int i = 0; i < len; i++)
      if (str[i] == '(')
        num1++;
      else
        num2++;
    if (abs(num1 - num2) != 2) {
      cout << 0 << endl;
      continue;
    }
    int ans = 0;
    for (int i = 0; i < len; i++) {
      if (str[i] == '(') {
        if (num1 - num2 == 2 && Min3[i] >= 2 && Min1[i - 1] >= 0) {
          ans++;
        }
      } else {
        if (num2 - num1 == 2 && Min3[i] >= -2 && Min1[i - 1] >= 0) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
