#include <bits/stdc++.h>
using namespace std;
int n;
char s[5003];
int main() {
  scanf("%s", s);
  n = (int)strlen(s);
  int ans = 0;
  for (int i = 1; i < n; i++) {
    int h = 0, wc = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == '(') {
        if (h == 0) {
          if (wc == 0) break;
          wc--;
          h++;
        } else
          h--;
      } else if (s[j] == ')') {
        h++;
      } else {
        if (h == 0) {
          h++;
        } else {
          h--;
          wc++;
        }
      }
      if (h & 1) continue;
      if (h <= 0 && -h / 2 <= wc) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
