#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  int n = str.size(), i, j;
  int countNet = 0, countQues = 0, diff;
  int countPretty = 0;
  for (i = 0; i < n; i++) {
    countNet = 0;
    countQues = 0;
    for (j = i; j < n; j++) {
      if (str[j] == '(') {
        countNet++;
      } else if (str[j] == ')') {
        countNet--;
      } else {
        countQues++;
      }
      if (countNet + countQues < 0) break;
      diff = countQues - countNet;
      if (diff > 0) {
        countNet += ((diff + 1) / 2);
        countQues -= ((diff + 1) / 2);
      }
      if ((j - i + 1) % 2) continue;
      if (countQues >= countNet) countPretty++;
    }
  }
  cout << countPretty << endl;
  fclose(stdin);
  fclose(stdout);
}
