#include <bits/stdc++.h>
using namespace std;
bool isvowel(char c) {
  c = tolower(c);
  return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long fastpow(long long base, long long p) {
  if (p == 0) return 1;
  long long num = fastpow(base, p / 2);
  num *= num;
  if (p % 2) num *= base;
  return num;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  string s;
  int ans = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    int open = 0, marks = 0;
    bool bad = false;
    for (int j = i; j < s.size(); j++) {
      if (open == 0) ans++;
      if (s[j] == '(') open++;
      if (s[j] == '?') {
        if (!open)
          open++;
        else
          open--, marks++;
      }
      if (s[j] == ')') {
        if (open) {
          open--;
        } else {
          if (!marks) {
            bad = true;
            break;
          } else {
            marks--;
            open++;
          }
        }
      }
    }
    if (!open && !bad) ans++;
    ans--;
  }
  cout << ans;
  return 0;
}
