#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s;
  n = s.length();
  int left[n][n], right[n][n];
  memset(left, 0, sizeof left);
  memset(right, 0, sizeof right);
  for (int i = 0; i < n; i++) {
    bool ok = true;
    long long int cur = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == ')')
        cur--;
      else
        cur++;
      if (cur < 0) ok = false;
      left[i][j] = ok;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    bool ok = true;
    long long int cur = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == '(')
        cur--;
      else
        cur++;
      if (cur < 0) ok = false;
      right[j][i] = ok;
    }
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (left[i][j] && right[i][j] && (j - i) % 2) ans++;
    }
  }
  cout << ans << '\n';
}
