#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int vys = 0;
  for (int i = (0); i < (s.length()); i++) {
    int otaz = 0, zatial = 0;
    for (int j = (i); j < (s.length()); j++) {
      if (s[j] == '(') zatial++;
      if (s[j] == ')') zatial--;
      if (s[j] == '?') otaz++;
      if (otaz >= 1 && otaz > zatial) {
        zatial++;
        otaz--;
      }
      if (zatial < 0) break;
      if ((otaz + zatial) % 2 == 0 && otaz == zatial) vys++;
    }
  }
  cout << vys << "\n";
  return 0;
}
