Problem: As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside Down will know and relocate him. 

<image>

Thus, he came up with a puzzle to tell his mom his coordinates. His coordinates are the answer to the following problem.

A string consisting only of parentheses ('(' and ')') is called a bracket sequence. Some bracket sequence are called correct bracket sequences. More formally:

  * Empty string is a correct bracket sequence. 
  * if s is a correct bracket sequence, then (s) is also a correct bracket sequence. 
  * if s and t are correct bracket sequences, then st (concatenation of s and t) is also a correct bracket sequence. 



A string consisting of parentheses and question marks ('?') is called pretty if and only if there's a way to replace each question mark with either '(' or ')' such that the resulting string is a non-empty correct bracket sequence.

Will gave his mom a string s consisting of parentheses and question marks (using Morse code through the lights) and his coordinates are the number of pairs of integers (l, r) such that 1 ≤ l ≤ r ≤ |s| and the string slsl + 1... sr is pretty, where si is i-th character of s.

Joyce doesn't know anything about bracket sequences, so she asked for your help.

Input

The first and only line of input contains string s, consisting only of characters '(', ')' and '?' (2 ≤ |s| ≤ 5000).

Output

Print the answer to Will's puzzle in the first and only line of output.

Examples

Input

((?))


Output

4


Input

??()??


Output

7

Note

For the first sample testcase, the pretty substrings of s are:

  1. "(?" which can be transformed to "()". 
  2. "?)" which can be transformed to "()". 
  3. "((?)" which can be transformed to "(())". 
  4. "(?))" which can be transformed to "(())". 



For the second sample testcase, the pretty substrings of s are:

  1. "??" which can be transformed to "()". 
  2. "()". 
  3. "??()" which can be transformed to "()()". 
  4. "?()?" which can be transformed to "(())". 
  5. "??" which can be transformed to "()". 
  6. "()??" which can be transformed to "()()". 
  7. "??()??" which can be transformed to "()()()". 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 0ll;
const long long int INF = 3e18;
long long int power(long long int base, long long int exp) {
  long long int res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base);
    base = (base * base);
    exp /= 2;
  }
  return res;
}
long long int bitc(long long int n, long long int x) { return ((n >> x) & 1); }
long long int __gcd(long long int a, long long int b) {
  return b == 0 ? a : __gcd(b, a % b);
}
long long int fsub(long long int a, long long int b, long long int p = MOD) {
  return ((a % p) - (b % p) + p) % p;
}
long long int fmult(long long int a, long long int b, long long int p = MOD) {
  return ((((a % p) * (b % p)) % p) + p) % p;
}
long long int fadd(long long int a, long long int b, long long int p = MOD) {
  return ((a % p + b % p) % p + p) % p;
}
long long int fpow(long long int n, long long int k, long long int p = MOD) {
  long long int r = 1;
  while (k > 0) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
    k = k >> 1;
  }
  return r;
}
long long int inv(long long int a, long long int p = MOD) {
  return fpow(a, p - 2, p);
}
long long int fdiv(long long int a, long long int b, long long int p = MOD) {
  long long int yinv = inv(b);
  long long int ans = (a * yinv) % p;
  return ((ans) % p + p) % p;
}
long long int ceil(long long int a, long long int b) {
  return ceil((long double)a / b);
}
template <typename T>
istream &operator>>(istream &in, vector<T> &a) {
  for (auto &item : a) {
    in >> item;
  }
  return in;
}
template <typename T, typename U>
ostream &operator<<(ostream &out, pair<T, U> &a) {
  cout << a.first << " " << a.second;
  return out;
}
template <typename T, typename U>
istream &operator>>(istream &out, pair<T, U> &a) {
  cin >> a.first >> a.second;
  return out;
}
template <typename T, typename U>
ostream &operator<<(ostream &out, map<T, U> &a) {
  for (auto &item : a) {
    out << item << "\n";
  }
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &a) {
  for (auto &item : a) {
    out << item << " ";
  }
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, vector<vector<T>> &a) {
  for (auto &item : a) {
    out << item << "\n";
  }
  return out;
}
template <int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template <typename... Args>
  Vec(int n = 0, Args... args)
      : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}
};
template <typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, T val = T()) : vector<T>(n, val) {}
};
std::vector<bool> is_prime;
std::vector<long long int> primes;
void sieve(long long int n) {
  is_prime.resize(n + 2, true);
  primes.clear();
  long long int p;
  for (p = 2; p * p <= n; p++) {
    if (is_prime[p]) {
      long long int i;
      for (i = p * p; i <= n; i += p) {
        is_prime[i] = false;
      }
    }
  }
  is_prime[0] = is_prime[1] = false;
  long long int i;
  for (i = 2; i <= n; i++) {
    if (is_prime[i]) {
      primes.emplace_back(i);
    }
  }
}
map<long long int, long long int> prime_factors(long long int n) {
  map<long long int, long long int> s;
  long long int i;
  long long int tc = 0;
  while (n % 2 == 0) {
    tc++;
    n /= 2;
  }
  if (tc > 0) {
    s[2] = tc;
  }
  for (i = 3; i <= sqrt(n); i += 2) {
    tc = 0;
    while (n % i == 0) {
      tc++;
      n /= i;
    }
    if (tc > 0) {
      s[i] = tc;
    }
  }
  if (n > 2) {
    s[n] += 1;
  }
  return s;
}
std::vector<long long int> fact_vec;
void fact_fun(long long int n) {
  fact_vec.resize(n + 10);
  long long int i;
  fact_vec[0] = 1;
  for (i = 1; i <= n + 2; i++) {
    fact_vec[i] = (fact_vec[i - 1] * i) % MOD;
  }
}
std::vector<long long int> p2;
void power_2(long long int n, long long int m = MOD) {
  long long int i;
  p2.emplace_back(1);
  for (i = 0; i < n; i++) {
    p2.emplace_back(fmult(p2.back(), 2));
  }
}
long long int ncr(long long int n, long long int r) {
  if (r > n) return 0;
  return fdiv(fact_vec[n], fmult(fact_vec[r], fact_vec[n - r]));
}
std::vector<long long int> spf;
void sieve2(long long int MAXN) {
  MAXN += 10;
  spf.resize(MAXN, 0);
  spf[1] = 1;
  for (long long int i = 2; i < MAXN; i++) spf[i] = i;
  for (long long int i = 4; i < MAXN; i += 2) spf[i] = 2;
  for (long long int i = 3; i * i < MAXN; i++) {
    if (spf[i] == i) {
      for (long long int j = i * i; j < MAXN; j += i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
  }
}
const int mi[4] = {-1, 0, 1, 0}, mj[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1},
          d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
map<long long int, long long int> getFactorization(long long int x) {
  map<long long int, long long int> ret;
  while (x != 1) {
    ret[spf[x]]++;
    x = x / spf[x];
  }
  return ret;
}
class Sol {
 public:
  Sol() { long long int i, j; }
};
int main() {
  long long int i, j;
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int ti;
  ti = 1;
  while (ti--) {
    string s;
    cin >> s;
    long long int n = s.length();
    Vec<2, bool> f(n, n), g(n, n);
    for (i = 0; i < n; i++) {
      bool ok = true;
      long long int cur = 0;
      for (j = i; j < n; j++) {
        if (s[j] == ')') {
          cur--;
        } else {
          cur++;
        }
        if (cur < 0) {
          ok = false;
        }
        f[i][j] = ok;
      }
    }
    for (i = 0; i < n; i++) {
      bool ok = true;
      long long int cur = 0;
      for (j = i; j >= 0; j--) {
        if (s[j] == '(') {
          cur--;
        } else {
          cur++;
        }
        if (cur < 0) {
          ok = false;
        }
        g[j][i] = ok;
      }
    }
    long long int ans = 0;
    for (i = 0; i < n; i++) {
      for (j = i; j < n; j++) {
        if (f[i][j] && g[i][j] && (j - i + 1) % 2 == 0) {
          ans++;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}