#include <bits/stdc++.h>
using namespace std;
const int maxn = 5007;
char s[maxn];
int main() {
  scanf("%s", s);
  int ans = 0, n = strlen(s);
  for (int i = 0; i < n; i++) {
    int cnt1 = 0, cnt2 = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(') {
        cnt1++;
        cnt2++;
      } else if (s[j] == ')') {
        cnt1--;
        cnt2--;
      } else {
        cnt1--;
        cnt2++;
      }
      while (cnt1 < 0 && cnt2 > 0) cnt1 += 2;
      if (cnt2 < 0) break;
      if (cnt1 == 0) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
