#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sup = 0;
    int inf = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(')
        sup++, inf++;
      else if (s[j] == ')')
        sup--, inf--;
      else
        sup++, inf--;
      if (sup < 0) break;
      if (inf < 0) inf = 0;
      if ((j - i + 1) % 2 == 0 && inf == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
