#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  string s;
  cin >> s;
  for (unsigned int i = 0; i < s.length(); ++i) {
    int l = 0, r = 0;
    for (unsigned int j = i; j < s.length(); ++j) {
      if (s[j] == '(') ++l, ++r;
      if (s[j] == ')') --l, --r;
      if (s[j] == '?') --l, ++r;
      if (r < 0) break;
      if (l < 0) l += 2;
      if (l <= 0 && r >= 0 && r % 2 == 0) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
