#include <bits/stdc++.h>
const int N = 5005;
short can[N][N];
char a[N];
int main() {
  scanf("%s", a + 1);
  int n = strlen(a + 1);
  for (int i = 1; i <= n; i++) {
    int now = 0;
    for (int j = i; j <= n; j++) {
      if (a[j] == ')') now--;
      if (a[j] == '(' || a[j] == '?') now++;
      if (now < 0) break;
      can[i][j]++;
    }
  }
  for (int i = n; i >= 1; i--) {
    int now = 0;
    for (int j = i; j >= 1; j--) {
      if (a[j] == ')' || a[j] == '?') now--;
      if (a[j] == '(') now++;
      if (now > 0) break;
      can[j][i]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++)
      if ((j - i + 1) % 2 == 0 && can[i][j] == 2) ans++;
  printf("%d", ans);
  return 0;
}
