#include <bits/stdc++.h>
using namespace std;
bool first[5005][5005], G[5005][5005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  int n = str.size();
  long long int ans = 0;
  for (int L = 0; L < n; L++) {
    bool ok = true;
    int cur = 0;
    for (int R = L; R < n; R++) {
      if (str[R] == ')')
        cur--;
      else
        cur++;
      if (cur < 0) ok = false;
      first[L][R] = ok;
    }
  }
  for (int L = 0; L < n; L++) {
    bool ok = true;
    int cur = 0;
    for (int R = L; R >= 0; R--) {
      if (str[R] == '(')
        cur--;
      else
        cur++;
      if (cur < 0) ok = false;
      G[R][L] = ok;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++)
      if ((j - i + 1) % 2 == 0 && first[i][j] && G[i][j]) ans++;
  cout << ans;
  return 0;
}
