#include <bits/stdc++.h>
using namespace std;
int fu[5010][5010];
int main() {
  int n, m = 0;
  string s;
  cin >> s;
  n = s.length();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    m = 0;
    for (int j = i; j < n; j++) {
      if (s[j] != ')')
        m++;
      else
        m--;
      if (m < 0) {
        for (int k = j; k < n; k++) fu[i][k] = -1;
        break;
      }
      fu[i][j] = m;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    m = 0;
    for (int j = i + 1 - 1; j >= 0; j--) {
      if (s[j] != '(')
        m++;
      else
        m--;
      if (m < 0) break;
      if (fu[j][i] < 0) continue;
      if (fu[j][i] % 2 == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
