#include <bits/stdc++.h>
using namespace std;
char s[5010];
int dp[5010];
int ans = 0;
signed main() {
  std::ios::sync_with_stdio(false);
  cin >> s + 1;
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    int ff = 0;
    int dd = 0;
    int pp = 0;
    if (s[i] == ')')
      dp[i] = -1, pp++;
    else {
      if (s[i] == '(')
        dp[i] = 1, dd++;
      else
        ff++;
    }
    for (int j = i + 1; j <= n; j++) {
      if (dp[j - 1] == -1) break;
      if (s[j] == ')') {
        dp[j] = max(dp[j - 1] - 1, 0);
        pp++;
        if (ff + dd < pp) dp[j] = -1;
        if (dp[j] != 0) continue;
        if (!((ff - (dd - pp)) & 1) && !((j - i + 1) & 1)) ans++;
      }
      if (s[j] == '(') dp[j] = dp[j - 1] + 1, dd++;
      if (s[j] == '?') {
        dp[j] = max(dp[j - 1] - 1, 0);
        ff++;
        if (dp[j] != 0) continue;
        if (!((ff - (dd - pp)) & 1) && !((j - i + 1) & 1)) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
