#include <bits/stdc++.h>
using namespace std;
char s[5005];
int n;
void clean() {}
void solve() {
  clean();
  n = strlen(s + 1);
  int ans = 0;
  for (int l = 1; l <= n; l++) {
    int taki = 0, wh = 0;
    for (int r = l; r <= n; r++) {
      if (s[r] == '(') taki++;
      if (s[r] == ')') taki--;
      if (s[r] == '?') {
        if (taki > 0)
          taki--, wh++;
        else
          taki++;
      }
      while (taki < 0 && wh) wh--, taki += 2;
      if (taki < 0) break;
      if (taki == 0) ans++;
    }
  }
  printf("%d\n", ans);
}
int main() {
  scanf("%s", s + 1), solve();
  return 0;
}
