#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  string S;
  cin >> S;
  int N = (int)(S).size(), ans = 0;
  for (int(p) = (0); (p) < (int)(N); ++(p)) {
    int cnt = 0, can = 0, q = 0;
    for (int(i) = (p); (i) < (int)(N); ++(i)) {
      char c = S[i];
      if (c == '(') {
        cnt++;
      }
      if (c == ')') {
        cnt--;
      }
      if (c == '?') {
        q++;
        can++;
      }
      if (cnt >= 0) (can) = min((can), (cnt));
      (can) = max((can), (0));
      if (cnt < 0 && q <= 0) break;
      if (cnt < 0) {
        cnt++;
        q--;
        (can) = min((can), (q));
      }
      if (cnt == can && (q - can) % 2 == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
