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;
void scan() {}
template <typename T, typename... Args>
void scan(T &a, Args &...args) {
  scanf("%lld", &a);
  scan(args...);
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
void solve() {
  ;
  long long n;
  ;
  { scan(n); };
  ;
  string str;
  cin >> str;
  bool flag = false;
  long long c = 0, ans = 0;
  for (__typeof((long long)str.size()) i =
           (0) - ((0) > ((long long)str.size()));
       i != ((long long)str.size()) - ((0) > ((long long)str.size()));
       i += 1 - 2 * ((0) > ((long long)str.size()))) {
    if (str[i] == '(')
      c++;
    else
      c--;
  }
  stack<long long> st;
  if (c == 2) {
    for (__typeof((long long)str.size()) i =
             (0) - ((0) > ((long long)str.size()));
         i != ((long long)str.size()) - ((0) > ((long long)str.size()));
         i += 1 - 2 * ((0) > ((long long)str.size())))
      if (st.empty() && str[i] == ')') {
        ;
        printf("%lld\n", 0ll);
        ;
        return;
      } else if (str[i] == ')') {
        st.pop();
        if (st.size() <= 1) ans = 0;
      } else if (!st.empty()) {
        st.push(1ll);
        ans++;
      } else {
        st.push(1ll);
      }
  } else if (c == -2) {
    reverse(str.begin(), str.end());
    for (__typeof((long long)str.size()) i =
             (0) - ((0) > ((long long)str.size()));
         i != ((long long)str.size()) - ((0) > ((long long)str.size()));
         i += 1 - 2 * ((0) > ((long long)str.size())))
      if (st.empty() && str[i] == '(') {
        ;
        printf("%lld\n", 0ll);
        ;
        return;
      } else if (str[i] == '(') {
        st.pop();
        if (st.size() <= 1) ans = 0;
      } else if (!st.empty()) {
        st.push(1ll);
        ans++;
      } else {
        st.push(1ll);
      }
  };
  printf("%lld\n", ans);
  ;
}
int main() {
  solve();
  return 0;
}
