#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int bracket = 0, questions = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(')
        bracket++;
      else if (s[j] == ')') {
        if (bracket == 0) {
          if (questions > 0) {
            questions--;
            bracket++;
          } else
            break;
        } else
          bracket--;
      } else {
        if (bracket == 0)
          bracket++;
        else {
          bracket--;
          questions++;
        }
      }
      if (bracket == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
