#include <bits/stdc++.h>
using namespace std;
string s;
int n, ans = 0, mi, mx, mxsuf[5007][5007];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  n = (int)s.length();
  for (int i = n - 1; i >= 0; i--) {
    int cur = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == '(')
        cur--;
      else
        cur++;
      mxsuf[j][i] = min(mxsuf[j + 1][i], cur);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    mx = 0;
    mi = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(')
        mi++, mx++;
      else if (s[j] == ')')
        mi--, mx--;
      else
        mi--, mx++;
      if (mx < 0) break;
      if ((j - i) % 2 == 1) {
        if (mx >= 0 && mi <= 0 && mxsuf[i][j] >= 0) ans++;
      }
    }
  }
  cout << ans;
}
