#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int low = 0, high = 0;
    for (int j = i; j < n; ++j) {
      if (s[j] == '(') {
        ++low, ++high;
      } else if (s[j] == ')') {
        --low, --high;
      } else {
        --low, ++high;
      }
      low = max(0, low);
      if (low == 0 && high >= 0 && high % 2 == 0) {
        ++ans;
      }
      if (high < 0) {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
