#include <bits/stdc++.h>
using namespace std;
const long long MX = 5e3 + 100, INF = 1e18, INF2 = -1e18, D = 1e9 + 7;
long long st, ed, q, p, pq;
void res() {
  p = 0;
  q = 0;
  pq = 0;
  st++;
  ed = st;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long n = s.size();
  long long ans = 0;
  while (s[st] == ')') st++;
  ed = st;
  while (st < n - 1) {
    if (ed >= n) {
      res();
      continue;
    }
    if (s[ed] == ')') {
      p--;
      if (p < pq) pq = max(pq - 1, (long long)0);
    } else {
      if (s[ed] == '(') {
        p++;
        ed++;
        continue;
      } else {
        if (pq < p) pq++;
        q++;
      }
    }
    if (p < 0) {
      if (!q) {
        res();
        continue;
      } else {
        q--;
        p = 0;
        if (q % 2 == 0) ans++;
        ed++;
        continue;
      }
    }
    if (p - pq == 0 && (q - pq) % 2 == 0) ans++;
    ed++;
  }
  cout << ans;
  return 0;
}
