#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  long long l = s.length();
  long long ans = 0;
  for (long long i = 0; i < l; i++) {
    long long c1 = 0, c2 = 0;
    for (long long j = i; j < l; j++) {
      if (s[j] == '(') {
        c1++;
      } else if (s[j] == ')') {
        c1--;
      } else {
        c1--;
        c2++;
      }
      if (c1 < 0) {
        if (c2 == 0) {
          break;
        } else {
          c2--;
          c1 += 2;
        }
      }
      if (c1 == 0) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
