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