#include <bits/stdc++.h>
using namespace std;
bool leftToRight[5004][5004];
bool rightToLeft[5004][5004];
int main() {
  string inp;
  cin >> inp;
  int len = inp.size();
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < len; j++) {
      leftToRight[i][j] = true;
      rightToLeft[i][j] = true;
    }
  }
  for (int i = 0; i < len; i++) {
    int curr = 0;
    bool ok = true;
    for (int j = i; j < len; j++) {
      if (inp[j] == ')')
        curr--;
      else
        curr++;
      if (curr < 0) ok = false;
      leftToRight[i][j] = ok;
    }
  }
  for (int i = 0; i < len; i++) {
    int curr = 0;
    bool ok = true;
    for (int j = i; j >= 0; j--) {
      if (inp[j] == '(')
        curr--;
      else
        curr++;
      if (curr < 0) ok = false;
      rightToLeft[j][i] = ok;
    }
  }
  int ans = 0;
  for (int i = 0; i < len; i++) {
    for (int j = i; j < len; j++) {
      if (leftToRight[i][j] && rightToLeft[i][j] && (j - i + 1) % 2 == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
