int l[maxn], r[maxn]; intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> s + 1; n = strlen(s + 1); for (int i = 1; i <= n; ++i) { int p = i, sum = 0; while (sum >= 0 && p <= n) { if (s[p++] == ')') --sum; else ++sum; } l[i] = p - 1; } for (int i = 1; i <= n; ++i) { int p = i, sum = 0; while (sum >= 0 && p >= 1) { if (s[p--] == '(') --sum; else ++sum; } r[i] = p + 1; } int ans = 0; for (int i = 1; i <= n; ++i) for (int j = i; j <= l[i]; ++j) if (r[j] <= i && j - i & 1) ++ans; cout << ans << "\n"; return0; }