#include <bits/stdc++.h>
using namespace std;
constexpr int N = 5000 + 10;
long long ans;
string s;
vector<int> v[N];
bool is[N][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  for (int i = (int)s.size() - 2; ~i; i--) {
    if (s[i] == '?' || s[i] == '(') {
      for (int j = i + 1; j < (int)s.size(); j++) {
        if (s[j] == '?' || s[j] == ')') {
          if ((i + 1) == j || is[i + 1][j - 1]) {
            if (!is[i][j]) {
              is[i][j] = true;
              v[i].push_back(j);
            } else
              continue;
            for (auto k : v[j + 1]) {
              if (is[i][k]) continue;
              is[i][k] = true;
              v[i].push_back(k);
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < (int)s.size(); i++) {
    ans += (int)v[i].size();
  }
  cout << ans << '\n';
  return 0;
}
