#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = s.size(), res = 0;
  for (int i = 0; i < l; i++) {
    int o = 0, m = 0;
    for (int j = i; j < l; j++) {
      o += (s[j] == '(');
      o -= (s[j] == ')');
      m += (s[j] == '?');
      if (m == 0 && o < 0) break;
      if (m > o) swap(m, o);
      if (m == o) res++;
    }
  }
  cout << res;
}
