#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
string s;
int n, ans;
bool ok[maxn][maxn];
int main() {
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    int l = 0, r = 0, q = 0;
    for (int j = 0; i + j < n; j++) {
      if (s[i + j] == '(')
        l++;
      else if (s[i + j] == '?')
        q++;
      else
        r++;
      if (l + q < r) break;
      ok[i][i + j] = true;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    int l = 0, r = 0, q = 0;
    for (int j = 0; i - j >= 0; j++) {
      if (s[i - j] == '(')
        l++;
      else if (s[i - j] == '?')
        q++;
      else
        r++;
      if (r + q < l) break;
      if (ok[i - j][i] && j % 2 == 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
