#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 10;
char s[maxn];
int n, sum, cnt, lst, ans;
bool vis[maxn][maxn];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    sum = cnt = 0;
    for (int j = i; j <= n; j++) {
      if (s[j] == '(') sum++;
      if (s[j] == ')') sum--;
      if (s[j] == '?') cnt++;
      if (sum + cnt < 0) break;
      if ((j - i + 1) % 2 == 0) {
        if (sum - cnt <= 0) vis[i][j] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sum = cnt = 0;
    for (int j = i; j; j--) {
      if (s[j] == '(') sum++;
      if (s[j] == ')') sum--;
      if (s[j] == '?') cnt++;
      if (sum - cnt > 0) break;
      if ((i - j + 1) % 2 == 0) {
        if (sum + cnt >= 0 && vis[j][i]) {
          ans++;
        } else
          vis[j][i] = 0;
      }
    }
  }
  printf("%d\n", ans);
}
