#include <bits/stdc++.h>
using namespace std;
template <class U, class T>
void Max(U &first, T second) {
  if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
  if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
  a = (a + b) % 998244353;
}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 998244353;
    a = 1LL * a * a % 998244353;
    b >>= 1;
  }
  return ans;
}
int pow(int a, int b, int c) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % c;
    a = 1LL * a * a % c;
    b >>= 1;
  }
  return ans;
}
int dp[3], ndp[3];
char s[200010 * 5];
int main() {
  int ca = 0, T, k, i, j, m = 0, n;
  double start = clock();
  scanf("%d%s", &n, s);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    k = (s[i] == '(' ? 1 : -1);
    for (int j = 0; j < 3; j++) ndp[j] = 0;
    if (dp[0]) {
      if (m + k >= 0) ndp[0] = dp[0];
      if (m - k >= 0) ndp[k < 0 ? 1 : 2] += dp[0];
    }
    if (dp[1]) {
      if (m + 2 + k >= 0) ndp[1] += dp[1];
    }
    if (dp[2]) {
      if (m - 2 + k >= 0) ndp[2] += dp[2];
    }
    m += k;
    swap(dp, ndp);
  }
  int ans = 0;
  if (m == 2 && dp[2])
    ans = dp[2];
  else if (m == -2 && dp[1])
    ans = dp[1];
  printf("%d\n", ans);
  cerr << (1. * clock() - start) / CLOCKS_PER_SEC << "\n";
}
