#include <bits/stdc++.h>
using namespace std;
int ok[5100][5100];
int main() {
  char str[6000];
  scanf("%s", str);
  int i, j, n = strlen(str);
  for (i = 0; i < n; i++) {
    int l = 0, r = 0;
    for (j = i; j < n; j++) {
      if (str[j] == '(' || str[j] == '?')
        l++;
      else
        r++;
      if (r > l) break;
      if ((j - i) % 2 == 1) ok[i][j] += 1;
    }
  }
  for (i = n - 1; i >= 0; i--) {
    int l = 0, r = 0;
    for (j = i; j >= 0; j--) {
      if (str[j] == ')' || str[j] == '?')
        r++;
      else
        l++;
      if (l > r) break;
      if ((i - j) % 2 == 1) ok[j][i] += 1;
    }
  }
  int ans = 0;
  for (i = 0; i < n; i++)
    for (j = i; j < n; j++)
      if (ok[i][j] == 2) ans++;
  printf("%d\n", ans);
  return 0;
}
