#include <bits/stdc++.h>
using namespace std;
int toint(const string &s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
string tostring(int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long ans = pw(a, b / 2);
  if (b & 1) return (((ans * ans) % 1000000007 * a) % 1000000007);
  return (ans * ans) % 1000000007;
}
long long const NMAX = 2e5 + 20;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int qmarks = 0, score = 0;
    for (int j = i; j < n && qmarks <= score; j++) {
      qmarks += (s[j] == '?');
      score += (s[j] == '(') - (s[j] == ')');
      int dec = min(max(0, qmarks - score), qmarks);
      qmarks -= dec;
      score += dec;
      ans += (qmarks == score);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
