#include <bits/stdc++.h>
using namespace std;
char a[100010];
int main() {
  int n;
  scanf("%s", a);
  n = strlen(a);
  int ans = 0, nm = 0, nm1 = 0, open, close;
  for (int i = 0; i < n; ++i) {
    nm = 0;
    nm1 = 0;
    open = 0;
    close = 0;
    for (int j = i; j < n; ++j) {
      if (a[j] == '?') {
        ++open;
        ++close;
      } else if (a[j] == ')') {
        --nm;
      } else {
        ++nm;
      }
      close = min(close, max(0, nm));
      if (nm == 0) {
        if ((j - i + 1) % 2 == 0) ++ans;
      } else if (nm < 0) {
        if (open >= -nm) {
          if (((j - i + 1) % 2 == 0)) {
            ++ans;
          }
          open += nm;
          nm = 0;
        } else
          break;
      } else if (nm > 0) {
        if (close >= nm && ((j - i + 1) % 2 == 0)) ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
