#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
class modint {
  int v;

 public:
  modint() : v(0) {}
  modint(long long v) : v((v + MOD) % MOD) {}
  bool operator==(modint x) { return v == x.v; }
  bool operator!=(modint x) { return v != x.v; }
  modint operator+(modint x) { return v + x.v; }
  modint operator-(modint x) { return v - x.v; }
  modint operator*(modint x) { return (long long)v * x.v; }
  modint operator/(modint x) { return *this * x.inv(); }
  modint& operator+=(const modint x) { return *this = (*this + x); }
  modint& operator-=(const modint x) { return *this = (*this - x); }
  modint& operator*=(const modint x) { return *this = (*this * x); }
  modint& operator/=(const modint x) { return *this = (*this / x); }
  int operator*() { return v; }
  modint inv() {
    modint ret = 1, cur = v;
    int p = MOD - 2;
    while (p > 0) {
      if (p & 1) ret = ret * cur;
      cur = cur * cur;
      p >>= 1;
    }
    return ret;
  }
};
char S[5050];
int N;
int L[5050], R[5050];
int main() {
  scanf("%s", S);
  N = strlen(S);
  for (int i = 0; i < N; i++) {
    L[i] = -1;
    for (int j = i, c = 0; j >= 0; j--) {
      c += (S[j] == '(') ? -1 : +1;
      if (c < 0) {
        L[i] = j;
        break;
      }
    }
    R[i] = N;
    for (int j = i, c = 0; j < N; j++) {
      c += (S[j] == ')') ? -1 : +1;
      if (c < 0) {
        R[i] = j;
        break;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if ((j - i + 1) % 2 == 0 && R[i] > j && L[j] < i) {
        ans += 1;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
