#include <bits/stdc++.h>
using namespace std;
using li = long long;
using ld = long double;
using pii = pair<li, li>;
const int INF = 1e9 + 14;
const int M = 998244353;
const int N = 5000 + 13;
bool is[N][N];
int main() {
  string second;
  cin >> second;
  int ans = 0;
  set<pii> st;
  for (int i = second.size() - 1; i >= 0; i--) {
    int a = 0, b = 0;
    for (int j = i; j >= 0; j--) {
      if (second[j] == ')')
        a++;
      else if (second[j] == '(')
        a--;
      else {
        a++;
        b++;
      }
      if (a < 0) break;
      if ((j - i + 1) % 2 == 0 && a - 2 * b <= 0) {
        is[j][i] = true;
      }
    }
  }
  for (int i = 0; i < second.size(); i++) {
    int a = 0, b = 0;
    for (int j = i; j < second.size(); j++) {
      if (second[j] == '(')
        a++;
      else if (second[j] == ')')
        a--;
      else {
        a++;
        b++;
      }
      if (a < 0) break;
      if ((j - i + 1) % 2 == 0 && a - 2 * b <= 0) {
        ans += is[i][j];
      }
    }
  }
  cout << ans << endl;
}
