#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string str;
  cin >> str;
  int n = str.length();
  bool dp[n + 1][n + 1], dp2[n + 1][n + 1];
  for (int i = 1; i <= n; i++) {
    bool ok = true;
    int curr = 0;
    for (int j = i; j <= n; j++) {
      if (str[j - 1] == ')')
        curr--;
      else
        curr++;
      if (curr < 0) ok = false;
      dp[i][j] = ok;
    }
  }
  for (int i = 1; i <= n; i++) {
    bool ok = true;
    int curr = 0;
    for (int j = i; j >= 0; j--) {
      if (str[j - 1] == '(')
        curr--;
      else
        curr++;
      if (curr < 0) ok = false;
      dp2[j][i] = ok;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (dp[i][j] && dp2[i][j] && (j - i + 1) % 2 == 0) ans++;
    }
  }
  cout << ans << endl;
}
