#include <bits/stdc++.h>
using ::std::cin;
using ::std::cout;
using ::std::endl;
using ::std::max;
using ::std::string;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int result = 0;
  for (int l = 0; l < n; ++l) {
    int minOpened = 0, maxOpened = 0;
    for (int r = l; r < n; ++r) {
      if (s[r] == '(') {
        ++minOpened;
        ++maxOpened;
      } else if (s[r] == ')') {
        minOpened += minOpened > 0 ? -1 : +1;
        --maxOpened;
        if (maxOpened < minOpened) break;
      } else if (s[r] == '?') {
        minOpened += minOpened > 0 ? -1 : +1;
        ++maxOpened;
      }
      result += minOpened == 0;
    }
  }
  cout << result << endl;
  return 0;
}
