#include <bits/stdc++.h>
using namespace std;
int c, n, a[5002][5002], b[5002][5002];
string s;
int main() {
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) {
    int qm = 0, ob = 0, cb = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '?')
        qm++;
      else if (s[j] == '(')
        ob++;
      else
        cb++;
      if (ob + qm - cb >= 0)
        a[i][j] = 1;
      else
        break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    int qm = 0, ob = 0, cb = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == '?')
        qm++;
      else if (s[j] == ')')
        ob++;
      else
        cb++;
      if (ob + qm - cb >= 0)
        b[j][i] = 1;
      else
        break;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if ((j - i + 1) % 2 == 0 && a[i][j] && b[i][j]) c++;
    }
  }
  cout << c;
  return 0;
}
