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