#include <bits/stdc++.h>
using namespace std;
int arr[5005][5005], n;
int main() {
  string s;
  cin >> s;
  int bal = 0, q = 0, ans = 0, c;
  n = s.size();
  for (int i = 0; i < n; i++) {
    bal = 0, q = 0, c = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(')
        bal++;
      else if (s[j] == ')')
        bal--;
      else
        q++;
      if (bal < 0) {
        if (q) {
          q--, bal++, c++;
        } else {
          for (int k = j; k <= n; k++) arr[i][k] = -1;
          break;
        }
      }
      arr[i][j] = c;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    bal = 0, q = 0, c = 0;
    int cnt = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == ')')
        bal++;
      else if (s[j] == '(')
        bal--;
      else {
        q++;
        cnt++;
      }
      if (bal < 0) {
        if (!q) break;
        q--, bal++, c++;
      }
      int tmp = cnt - c - arr[j][i];
      if (tmp % 2 == 0 && arr[j][i] != -1) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
