#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int MOD = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  int len = s.length();
  int l, r, qq, ans, ck;
  ans = 0;
  for (int i = 0; i < len - 1; i++) {
    l = r = qq = ck = 0;
    for (int j = i; j < len; j++) {
      if (s[j] == '(') {
        l++;
        ck++;
      } else if (s[j] == ')') {
        r++;
        ck = max(0, min(ck, ck - 1));
      } else {
        qq++;
        ck = max(0, min(ck, ck - 1));
      }
      if (r > l + qq) break;
      if ((j - i + 1) % 2 == 0 && ck == 0 && (j - i + 1) / 2 >= l) ans++;
    }
  }
  printf("%d\n", ans);
}
