#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const long long INF = 1e18;
const int maxN = 5005;
string str;
int n;
bool OK[maxN][maxN], OK2[maxN][maxN];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int i, j, res, x, q;
  while (cin >> str) {
    memset(OK, 0, sizeof(OK));
    memset(OK2, 0, sizeof(OK2));
    res = 0;
    n = str.size();
    for (i = 0; i < n; i++) {
      x = q = 0;
      for (j = i; j < n; j++) {
        if (str[j] == '(' || str[j] == '?') {
          x++;
        } else {
          if (x > 0) {
            x--;
          } else {
            break;
          }
        }
        OK[i][j] = true;
      }
      x = 0;
      for (j = i; j >= 0; j--) {
        if (str[j] == ')' || str[j] == '?') {
          x++;
        } else {
          if (x > 0) {
            x--;
          } else {
            break;
          }
        }
        OK2[j][i] = true;
      }
    }
    for (i = 0; i < n; i++) {
      for (j = i + 1; j < n; j += 2) {
        if (OK[i][j] && OK2[i][j]) {
          res++;
        }
      }
    }
    cout << res << '\n';
  }
  return 0;
}
