#include <bits/stdc++.h>
int main(void) {
  std::string str;
  std::cin >> str;
  const long long n = str.length();
  std::vector<std::vector<std::pair<char, char>>> good(
      n, std::vector<std::pair<char, char>>(n));
  for (long long i = 0; i < n; ++i) {
    long long curr = 0;
    bool ok = true;
    for (long long j = i; j < n; ++j) {
      curr += (str[j] == ')' ? -1 : 1);
      ok = ok && curr >= 0;
      good[i][j].first = ok;
    }
  }
  for (long long j = 0; j < n; ++j) {
    long long curr = 0;
    bool ok = true;
    for (long long i = j; i >= 0; --i) {
      curr += (str[i] == '(' ? -1 : 1);
      ok = ok && curr >= 0;
      good[i][j].second = ok;
    }
  }
  long long result = 0;
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < n; ++j) {
      result += !((i - j + 1) % 2) && good[i][j].first && good[i][j].second;
    }
  }
  std::printf("%lld\n", result);
  return 0;
}
