#include <bits/stdc++.h>
const long long INF = 1e18 + 1;
const long long N = 1e5;
const long long MOD = 1e18 + 1;
using namespace std;
vector<long long> b;
vector<vector<pair<long long, char> > > g(N + 5);
long long n, m, k, r, x, y, l, c1, stc1, u, v, gu, c2, stc2, t, cur, stcur, ans,
    cnt, mn(INF), mx(-INF), a[N + 5];
char c;
string s;
bool f, fl, used[N + 5];
void read(long long &in) { scanf("%I64d", &in); }
void read(long long &in1, long long &in2) { scanf("%I64d%I64d", &in1, &in2); }
void read(long long &in1, long long &in2, long long &in3) {
  scanf("%I64d%I64d%I64d", &in1, &in2, &in3);
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long bpow(long long x, long long p) {
  long long res;
  if (p == 0) {
    return 1;
  } else {
    res = bpow(x, p / 2);
    res = (res * res) % MOD;
    if (p % 2 == 1) {
      res = (res * x) % MOD;
    }
    return res;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    cur = 0;
    c1 = 0;
    for (int j = i; j < s.length(); j++) {
      if (s[j] == '(') {
        cur++;
      } else if (s[j] == ')') {
        cur--;
      } else {
        if (cur == 0)
          cur++;
        else {
          cur--;
          c1++;
        }
      }
      if (cur + 2 * c1 < 0) break;
      if (cur < 0) {
        cur += 2;
        c1--;
      }
      if (cur == 0) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
