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;
inline bool isvowel(char c) {
  c = tolower(c);
  if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u')
    return 1;
  return 0;
}
const double eps = 0.000001;
const long double pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const long long MOD = 1e18 + 9;
const long long INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1e6 + 123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int n, m, k;
int p[N];
int f[N];
bool fail_p[N];
bool fail_f[N];
string s;
int main() {
  cin >> n >> s;
  s = '#' + s;
  int bal = 0;
  for (long long i = 1; i <= n; i++) {
    if (s[i] == '(')
      bal++;
    else
      bal--;
    fail_p[i] |= fail_p[i - 1];
    if (bal < 0) fail_p[i] = 1;
    p[i] = bal;
  }
  bal = 0;
  for (long long i = n; i >= 1; i--) {
    if (s[i] == '(')
      bal++;
    else
      bal--;
    fail_f[i] |= fail_f[i + 1];
    if (bal > 0) fail_f[i] = 1;
    f[i] = bal;
  }
  int ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (fail_p[i - 1]) continue;
    if (fail_f[i + 1]) continue;
    bal = p[i - 1] + f[i + 1];
    if (s[i] == '(') {
      bal--;
      if (!bal) ans++;
    } else {
      bal++;
      if (!bal) ans++;
    }
  }
  cout << ans;
  return 0;
}
