#include <bits/stdc++.h>
using namespace std;
int main() {
  string buf;
  cin >> buf;
  int L = buf.length();
  int ans = 0;
  for (int i = 0; i < L; ++i) {
    int scor = 0, qmarks = 0;
    for (int j = i; j < L; ++j) {
      if (buf[j] == '?') {
        ++qmarks;
      } else if (buf[j] == '(') {
        ++scor;
      } else if (buf[j] == ')') {
        --scor;
      }
      while (qmarks > 0 && qmarks > scor) {
        ++scor;
        --qmarks;
      }
      if (scor < 0) {
        break;
      }
      if ((scor + qmarks) % 2 != 0) {
        continue;
      }
      if (qmarks >= scor) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
}
