#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
char s[N];
int n;
int pos[N][2][N];
int main() {
  scanf("%s", s);
  n = (int)strlen(s);
  pos[n][0][0]++;
  for (int i = n - 1; i >= 0; i--) {
    int sum = 0;
    pos[i][0][0]++;
    for (int j = i; j >= 0; j--) {
      if (s[j] == ')' || s[j] == '?')
        sum++;
      else
        sum--;
      if (sum < 0) break;
      pos[j][(i - j + 1) & 1][sum]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(' || s[j] == '?')
        sum++;
      else
        sum--;
      if (sum < 0) break;
      if (s[j] == '?' || i == j) ans += pos[j + 1][(j - i + 1) & 1][sum];
    }
  }
  cout << ans << endl;
  return 0;
}
