#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = (((1 << 30) - 1) << 1) + 1;
const int nINF = 1 << 31;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  int n = s.size();
  int open, close, q, ans = 0;
  for (int i = 0; i < (n); i++) {
    open = 0, close = 0, q = 0;
    for (int j = (i); j <= (n - 1); j++) {
      if (s[j] == '(')
        ++open;
      else if (s[j] == ')')
        ++close;
      else {
        ++close;
        ++q;
      }
      if (close > open) {
        if (q) {
          --q;
          ++open;
          --close;
        } else
          break;
      }
      if ((i - j + 1) % 2 == 0 && open == close) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
