#include <bits/stdc++.h>
using namespace std;
string str;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> str;
  int N = str.size();
  long long res = 0;
  for (int i = 0; i < N; i++) {
    int act = 0, q = 0;
    int len = 0;
    for (int j = i; j < N; j++) {
      len++;
      act += (str[j] == '?') ? 0 : (str[j] == '(' ? 1 : -1);
      q += (str[j] == '?');
      if (act < 0) break;
      if (q > act) {
        q--;
        act++;
      }
      if (len % 2 == 0 && q >= act) {
        res++;
      }
    }
  }
  cout << res << '\n';
  return 0;
}
