#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  const int n = s.size();
  int count = 0;
  for (int l = 0; l < n; ++l) {
    int maxopen = 0;
    int minopen = 0;
    for (int r = l; r < n; ++r) {
      if (s[r] == '(') {
        maxopen++;
        minopen++;
      } else if (s[r] == ')') {
        maxopen--;
        minopen = max(0, minopen - 1);
        if (maxopen < 0) break;
      } else {
        maxopen++;
        minopen = max(0, minopen - 1);
      }
      if (minopen == 0 && (r - l) % 2 == 1) {
        count++;
      }
    }
  }
  cout << count << endl;
}
