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