#include <bits/stdc++.h>
using namespace std;
string s;
int n;
bool ok[5002][5002];
void build(int ind) {
  int o = 0, c = 0, ex = 0;
  for (int i = ind; i < n; i++) {
    if (s[i] == '(')
      o++;
    else if (s[i] == ')')
      c++;
    else
      ex++;
    if (ex > o - c) ex--, o++;
    if (ex < 0) return;
    int bal = o - c;
    if (bal < 0) return;
    if (ex >= bal && (ex - bal) % 2 == 0) ok[ind][i] = 1;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++) build(i);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      ans += ok[i][j];
    }
  }
  cout << ans;
}
