#include <bits/stdc++.h>
void mc(int *aa, int *a, int len) {
  for (int i = 1; i <= len; i++) *(aa + i) = *(a + i);
}
const int INF = 0x7FFFFFFF;
const double G = 10;
const double eps = 1e-6;
const double PI = acos(-1.0);
const int mod = 1e9 + 7;
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    int ans = 0;
    for (int i = 0; i <= s.size() - 1; i++) {
      int n_left_bracket = 0;
      int n_question = 0;
      for (int j = i; j <= s.size() - 1; j++) {
        if (s[j] == '(')
          n_left_bracket++;
        else if (s[j] == ')')
          n_left_bracket--;
        else
          n_left_bracket--, n_question++;
        if (n_left_bracket == 0)
          ans++;
        else if (n_left_bracket < 0) {
          if (n_question == 0)
            break;
          else if (n_question > 0)
            n_left_bracket += 2, n_question--;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
