#include <bits/stdc++.h>
using namespace std;
const int maxN = 5005;
int str[maxN];
bool right2[maxN][maxN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] == '?')
      str[i] = 1;
    else if (s[i] == '(')
      str[i] = 2;
    else if (s[i] == ')')
      str[i] = 3;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int dif = 0;
    for (int j = i; j < n; j++) {
      if (str[j] == 3)
        dif--;
      else
        dif++;
      if (dif < 0) break;
      if ((j - i) & 1) right2[j][i] = true;
    }
  }
  for (int j = n - 1; j >= 0; j--) {
    int dif = 0;
    for (int i = j; i >= 0; i--) {
      if (str[i] == 2)
        dif--;
      else
        dif++;
      if (dif < 0) break;
      if (((j - i) & 1) && right2[j][i]) ans++;
    }
  }
  cout << ans;
  return 0;
}
