#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::string s;
  std::cin >> s;
  int n = s.length();
  int answer = 0;
  for (int i = 0; i < n; i++) {
    int tot = 0, num = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(') ++tot;
      if (s[j] == ')') --tot;
      if (s[j] == '?') {
        if (tot > 0)
          --tot, ++num;
        else
          ++tot;
      }
      if (tot < 0 && num) tot += 2, num--;
      if (tot < 0 && !num) break;
      if (tot == 0) ++answer;
    }
  }
  std::cout << answer << '\n';
  return 0;
}
