#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  register T c = getchar();
  x = 0;
  int t = 0;
  if (c == '-') t = 1, c = getchar();
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (t) x = -x;
}
int dp[5005][5005];
int main() {
  string s;
  cin >> s;
  int ans = 0, cnt = 0;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    cnt = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == ')')
        cnt--;
      else
        ++cnt;
      if (cnt < 0) {
        for (int k = j; k < n; k++) dp[i][k] = -1;
        break;
      }
      dp[i][j] = cnt;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    cnt = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == '(')
        --cnt;
      else
        ++cnt;
      if (cnt < 0) break;
      if (dp[j][i] < 0) continue;
      if (dp[j][i] % 2 == 0) ++ans;
    }
  }
  cout << ans;
}
