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;
int sc(int &x) { return scanf("%d", &x); }
int sc(unsigned int &x) { return scanf("%u", &x); }
int sc(long long &x) { return scanf("%lld", &x); }
int sc(unsigned long long &x) { return scanf("%llu", &x); }
int sc(double &x) { return scanf("%lf", &x); }
int sc(long double &x) { return scanf("%Lf", &x); }
int sc(char *x) { return scanf("%s", x); }
int sc(char &x) { return scanf("%c", &x); }
template <typename T, typename... Args>
void sc(T &v, Args &...args) {
  sc(v);
  sc(args...);
}
void pr(const int &x) { printf("%d", x); }
void pr(const unsigned int &x) { printf("%u", x); }
void pr(const long long &x) { printf("%lld", x); }
void pr(const unsigned long long &x) { printf("%llu", x); }
void pr(const double &x) { printf("%.10lf", x); }
void pr(const long double &x) { printf("%.10Lf", x); }
void pr(const char *const &x) { printf("%s", x); }
void pr(char *const &x) { printf("%s", x); }
void pr(const char &x) { printf("%c", x); }
template <typename T, typename... Args>
void pr(T const &v, Args const &...args) {
  pr(v);
  pr(' ');
  pr(args...);
}
const int N = 1000010;
const int M = 1024;
const int mod = 1000000007;
inline void _add(int &a, int b) { a = (a + b) % mod; }
inline void _sub(int &a, int b) { a = (a + mod - b) % mod; }
inline void _mul(int &a, int b) { a = (long long)a * b % mod; }
inline int _Add(int a, int b) { return (a + b) % mod; }
inline int _Sub(int a, int b) { return (a + mod - b) % mod; }
inline int _Mul(int a, int b) { return (long long)a * b % mod; }
template <typename T>
inline void _max(T &a, T b) {
  if (b > a) a = b;
}
template <typename T>
inline void _min(T &a, T b) {
  if (b < a) a = b;
}
int pw(int a, int b) {
  int res(1);
  while (b) {
    if (b & 1) _mul(res, a);
    _mul(a, a);
    b >>= 1;
  }
  return res;
}
int pwM(int a, int b, int m) {
  int res(1);
  while (b) {
    if (b & 1) res = (long long)res * a % m;
    a = (long long)a * a % m;
    b >>= 1;
  }
  return res;
}
const int infi = 2147483647;
const long long infl = 9223372036854775807ll;
const double PI = 3.14159265358979323846;
const int inf = 1000000000 + 100;
int n, m, k, q, pre[N], suf[N];
char s[N];
int main() {
  sc(n), sc(s + 1);
  int p = 0;
  for (int i = 1, lim = n; i <= lim; ++i) {
    if (s[i] == '(')
      p++;
    else
      p--;
    if (p < 0) {
      for (int j = i, lim = n; j <= lim; ++j) pre[j] = -1;
      break;
    }
    pre[i] = p;
  }
  p = 0;
  for (int i = n, lim = 1; i >= lim; --i) {
    if (s[i] == ')')
      p++;
    else
      p--;
    if (p < 0) {
      for (int j = 1, lim = i; j <= lim; ++j) suf[j] = -1;
      break;
    }
    suf[i] = p;
  }
  int ans = 0;
  for (int i = 2, lim = n - 1; i <= lim; ++i) {
    if (pre[i - 1] == -1 || suf[i + 1] == -1) continue;
    if (s[i] == '(' && pre[i - 1] == suf[i + 1] + 1) ans++;
    if (s[i] == ')' && pre[i - 1] + 1 == suf[i + 1]) ans++;
  }
  if (n > 1 && s[1] == ')' && suf[2] == 1) ans++;
  if (n > 1 && s[n] == '(' && pre[n - 1] == 1) ans++;
  pr(ans), pr("\n");
  return 0;
}
