#include <bits/stdc++.h>
using namespace std;
char s[5009];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a = 0, c = 0, cc = 0;
    for (int j = i; j < n; ++j) {
      if (s[j] == '(')
        ++a;
      else if (s[j] == ')') {
        if (a) {
          if (cc == a) --cc;
          --a;
        } else if (c) {
          if (c == cc) --cc;
          --c;
        } else
          break;
      } else {
        if (a > cc) ++cc;
        ++c;
      }
      if (a == 0 && !(c & 1))
        ++ans;
      else if (a == cc && !((c - cc) & 1))
        ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}
