#include <bits/stdc++.h>
using namespace std;
string second;
int ans;
bool x[5555][5555];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> second;
  int n = second.size();
  for (int i = 0; i < n; i++) {
    int q = 0;
    int balance = 0;
    for (int j = i; j < n; j++) {
      if (second[j] == '?')
        balance++;
      else if (second[j] == ')')
        balance--;
      else if (second[j] == '(')
        balance++;
      if (balance < 0) break;
      if ((j - i) % 2 == 1 && second[j] != '(') {
        x[i][j] = true;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    int q = 0;
    int balance = 0;
    for (int j = i; j >= 0; j--) {
      if (second[j] == '?')
        balance++;
      else if (second[j] == ')')
        balance++;
      else if (second[j] == '(')
        balance--;
      if (balance < 0) break;
      if ((i - j) % 2 == 1 && second[j] != ')') {
        if (x[j][i]) {
          ans++;
        }
      }
    }
  }
  cout << ans;
  return 0;
}
