#include <bits/stdc++.h>
using namespace std;
string str;
bool f[5005][5005], b[5005][5005];
int cnt = 0, ans = 0;
bool ok = true;
int main(void) {
  cin >> str;
  int n, i = 0, j;
  n = str.length();
  for (i = 0; i < n; i++) {
    cnt = 0;
    ok = true;
    for (j = i; j < n; j++) {
      if (str[j] == ')')
        cnt--;
      else
        cnt++;
      if (cnt < 0) ok = false;
      f[i][j] = ok;
    }
  }
  for (i = n; i >= 0; i--) {
    cnt = 0;
    ok = true;
    for (j = i; j >= 0; j--) {
      if (str[j] == '(')
        cnt--;
      else
        cnt++;
      if (cnt < 0) ok = false;
      b[j][i] = ok;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (f[i][j] && b[i][j] && (j - i + 1) % 2 == 0) ans++;
    }
  }
  cout << ans;
  return 0;
}
