#include <bits/stdc++.h>
const double PI =
    3.141592653589793238462643383279502884197169399375105820974944;
using namespace std;
void solve() {
  string s;
  cin >> s;
  int len = s.length(), ans = 0;
  for (long long i = 0; i < len; ++i) {
    int score = 0, qmarks = 0;
    for (long long j = i; j < len; ++j) {
      if (s[j] == '?')
        ++qmarks;
      else if (s[j] == '(')
        ++score;
      else
        --score;
      while (qmarks > 0 && qmarks > score) {
        ++score;
        --qmarks;
      }
      if (score < 0) break;
      if ((qmarks + score) % 2 != 0) continue;
      if (qmarks >= score) {
        ++ans;
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  bool testing = false;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (testing) {
    freopen("test.txt", "rt", stdin);
    int start = clock();
    solve();
    int end = clock();
    cout << "time: " << (end - start) / (double)(CLOCKS_PER_SEC)*1000
         << " milliseconds\n";
  } else {
    solve();
  }
}
