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>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long power(long long a, long long b, long long m = 1000000007) {
  long long answer = 1;
  while (b) {
    if (b & 1) answer = (answer * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return answer;
}
using namespace std;
void ctrl() { cout << "Control" << endl; }
long long make_num(string p) {
  stringstream geek(p);
  long long x = 0;
  geek >> x;
  return x;
}
string make_str(long long x) {
  ostringstream str1;
  str1 << x;
  string geek = str1.str();
  return geek;
}
const long long N = 1000000 + 5;
long long high[4 * N + 10], low[4 * N + 10];
string p;
struct Node {
  long long balance, open, close;
};
struct Node Tree[4 * N + 10];
void init(long long node, long long start, long long end) {
  high[node] = end;
  low[node] = start;
  if (start == end) {
    return;
  }
  long long mid = (start + end) / 2;
  init(2 * node, start, mid);
  init(2 * node + 1, mid + 1, end);
}
struct Node combine(struct Node a, struct Node b) {
  struct Node res;
  long long x = min(a.open, b.close);
  res.balance = a.balance + b.balance + x;
  res.close = a.close + b.close - x;
  res.open = a.open + b.open - x;
  return res;
}
void build(long long node, long long start, long long end) {
  if (low[node] == high[node]) {
    if (p[low[node]] == '(')
      Tree[node].open = 1, Tree[node].close = 0;
    else {
      Tree[node].open = 0, Tree[node].close = 1;
    }
    Tree[node].balance = 0;
    return;
  }
  long long mid = (start + end) / 2;
  build(2 * node, start, mid);
  build(2 * node + 1, mid + 1, end);
  Tree[node] = combine(Tree[2 * node], Tree[2 * node + 1]);
}
struct Node query(long long node, long long start, long long end) {
  if (low[node] > end || high[node] < start || start > end)
    return Node{0, 0, 0};
  else if (start <= low[node] && end >= high[node]) {
    return Tree[node];
  }
  struct Node x = query(2 * node, start, end);
  struct Node y = query(2 * node + 1, start, end);
  struct Node res = combine(x, y);
  return res;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  long long n;
  cin >> n;
  init(1, 0, n - 1);
  cin >> p;
  build(1, 0, n - 1);
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    struct Node h = query(1, 0, i - 1);
    if (p[i] == ')') {
      h = combine(h, Node{0, 1, 0});
    } else {
      h = combine(h, Node{0, 0, 1});
    }
    h = combine(h, query(1, i + 1, n - 1));
    if (2 * h.balance == n) cnt++;
  }
  cout << cnt;
  return 0;
}
