#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
long long POWER[65];
void precompute() {
  POWER[0] = 1;
  for (int i = 1; i < 63; i++) POWER[i] = POWER[i - 1] << 1LL;
}
long long fastMul(long long a, long long b, long long mod) {
  long long res = 0;
  a %= mod;
  while (b) {
    if (b & 1) {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}
long long power(long long x, long long y, long long mod2) {
  long long res = 1;
  x %= mod2;
  while (y) {
    if (y & 1) res = fastMul(res, x, mod2);
    y >>= 1;
    x = fastMul(x, x, mod2);
  }
  return res;
}
long long inv(long long x, long long mod) { return power(x, mod - 2, mod); }
bool B[5002][5002];
bool A[5002][5002];
int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    int cur = 0;
    bool flag1 = true;
    for (int j = i; j < n; j++) {
      if (s[j] == ')')
        cur--;
      else
        cur++;
      if (cur < 0) flag1 = false;
      A[i][j] = flag1;
    }
  }
  for (int j = 0; j < n; j++) {
    int curr = 0;
    bool flag = true;
    for (int i = j; i >= 0; i--) {
      if (s[i] == '(')
        curr--;
      else
        curr++;
      if (curr < 0) flag = false;
      B[i][j] = flag;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (A[i][j] && B[i][j] && (j - i + 1) % 2 == 0) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
