#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  int t = 0;
  int qmarks = 0;
  int count = 0;
  for (size_t i = 0; i < s.length(); ++i) {
    t = 0;
    qmarks = 0;
    for (size_t j = i; j < s.length(); ++j) {
      if (s[j] == '(') {
        ++t;
      } else if (s[j] == ')')
        --t;
      else
        ++qmarks;
      if (qmarks > t) {
        if (qmarks > 0) {
          --qmarks;
          ++t;
        } else
          break;
      }
      if ((j - i + 1) % 2 == 0 && qmarks >= t) {
        ++count;
      }
    }
  }
  cout << count << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
