#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 5005;
int n;
string s;
bool x[maxn][maxn], y[maxn][maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  n = s.size();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool good = true;
    int cur = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(' || s[j] == '?')
        cur++;
      else
        cur--;
      if (cur < 0) good = false;
      x[i][j] = good;
    }
  }
  for (int i = 0; i < n; i++) {
    bool good = true;
    int cur = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == ')' || s[j] == '?')
        cur++;
      else
        cur--;
      if (cur < 0) good = false;
      y[j][i] = good;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (x[i][j] && y[i][j] && (j - i + 1) % 2 == 0) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
}
