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