#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  string s;
  cin >> s;
  int sz = (int)s.size();
  int question = 0;
  int balance = 0;
  for (int i = 0; i < sz; i++) {
    if (s[i] == ')') continue;
    question = 0;
    balance = 0;
    for (int j = i; j < sz; j++) {
      if (s[j] == ')') {
        balance--;
      }
      if (s[j] == '(') {
        balance++;
      }
      if (s[j] == '?') {
        question++;
        balance--;
      }
      if (balance < 0) {
        if (question > 0) {
          balance += 2;
          question--;
        } else
          break;
      }
      if (balance == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
