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;
class SegmentTree {
 private:
  vector<int> lazy, st, A;
  int n;
  int left(int i) { return 2 * i; }
  int right(int i) { return 2 * i + 1; }
  void build(int p, int L, int R) {
    if (L == R) {
      st[p] = A[L];
    } else {
      build(left(p), L, (L + R) / 2);
      build(right(p), (L + R) / 2 + 1, R);
      int p1 = left(p);
      int p2 = right(p);
      st[p] = min(st[p1], st[p2]);
    }
  }
  int rmqu(int node, int start, int end, int l, int r) {
    if (start > end || start > r || end < l) {
      return INT_MAX;
    }
    if (lazy[node] != 0) {
      st[node] += lazy[node];
      if (start != end) {
        lazy[node * 2] += lazy[node];
        lazy[2 * node + 1] += lazy[node];
      }
      lazy[node] = 0;
    }
    if (start >= l && end <= r) {
      return st[node];
    }
    int mid = (start + end) / 2;
    int p1 = rmqu(node * 2, start, mid, l, r);
    int p2 = rmqu(node * 2 + 1, mid + 1, end, l, r);
    return min(p1, p2);
  }
  void updateRange(int node, int start, int end, int l, int r, int val) {
    if (lazy[node] != 0) {
      st[node] += lazy[node];
      if (start != end) {
        lazy[node * 2] += lazy[node];
        lazy[2 * node + 1] += lazy[node];
      }
      lazy[node] = 0;
    }
    if (start > end || start > r || end < l) {
      return;
    }
    if (start >= l && end <= r) {
      st[node] += val;
      if (start != end) {
        lazy[node * 2] += val;
        lazy[node * 2 + 1] += val;
      }
      return;
    }
    int mid = (start + end) / 2;
    updateRange(node * 2, start, mid, l, r, val);
    updateRange(node * 2 + 1, mid + 1, end, l, r, val);
    st[node] = min(st[node * 2], st[node * 2 + 1]);
  }

 public:
  SegmentTree(const vector<int> &_A) {
    A = _A;
    n = A.size();
    st.assign(4 * n, 0);
    lazy.assign(4 * n, 0);
    build(1, 0, n - 1);
  }
  int rmq(int i, int j) { return rmqu(1, 0, n - 1, i, j); }
  void updateRange(int i, int j, int val) {
    updateRange(1, 0, n - 1, i, j, val);
  }
};
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> c;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      sum++;
    } else {
      sum--;
    }
    c.push_back(sum);
  }
  SegmentTree T(c);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      T.updateRange(i, n - 1, -2);
      if (T.rmq(0, n - 1) == 0 && T.rmq(n - 1, n - 1) == 0) {
        count++;
      }
      T.updateRange(i, n - 1, 2);
    } else {
      T.updateRange(i, n - 1, 2);
      if (T.rmq(0, n - 1) == 0 && T.rmq(n - 1, n - 1) == 0) {
        count++;
      }
      T.updateRange(i, n - 1, -2);
    }
  }
  cout << count << endl;
}
