#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
const long long inf = 2147383647;
const long long mod = 1000000007;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
int t, n;
int main() {
  string s;
  cin >> s;
  n = ((long long)(s).size());
  int ans = 0, cnt, found;
  for (long long i = (0); i <= (n - 1); ++i) {
    cnt = 0;
    found = 0;
    int val = 0;
    for (long long j = (i); j <= (n - 1); ++j) {
      if (s[j] == '(')
        cnt++;
      else if (s[j] == ')') {
        cnt--;
        if (cnt < 0) {
          if (val) {
            val--;
            cnt += 2;
          }
        }
      } else {
        found = 1;
        if (cnt) {
          cnt--;
          val++;
        } else {
          cnt++;
        }
      }
      if (cnt < 0) break;
      if (!cnt) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
