#include <bits/stdc++.h>
using namespace std;
bool found[5001][5001];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  long long int ans = 0;
  for (long long int i = 0; i < (long long int)(s.length()); i++) {
    long long int c, o, q;
    c = o = q = 0;
    for (long long int j = i; j < s.length(); j++) {
      if (s[j] == '(')
        o++;
      else if (s[j] == ')')
        c++;
      else
        q++;
      long long int temp = min(max(c - o, 0LL), q);
      o += temp;
      q -= temp;
      if (o < c) break;
      if ((j - i + 1) % 2 == 0 && o <= (j - i + 1) / 2 &&
          (s[j] == ')' || s[j] == '?')) {
        found[i][j] = true;
      }
    }
  }
  for (long long int i = (long long int)s.length() - 1; i >= 0; i--) {
    long long int c, o, q;
    c = o = q = 0;
    for (long long int j = i; j >= 0; j--) {
      if (s[j] == '(')
        c++;
      else if (s[j] == ')')
        o++;
      else
        q++;
      long long int temp = min(max(c - o, 0LL), q);
      o += temp;
      q -= temp;
      if (o < c) break;
      if ((i - j + 1) % 2 == 0 && o <= (i - j + 1) / 2 &&
          (s[j] == '(' || s[j] == '?')) {
        if (found[j][i]) ans++;
      }
    }
  }
  cout << ans;
}
