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 double PI = acos(-1);
int sgn(double x) { return (x > 1e-10) - (x < -1e-10); }
struct TPoint {
  double x, y;
  TPoint(double _x = 0, double _y = 0) : x(_x), y(_y) {}
  void show() {
    cout << "x" << '=' << x << " , ", cout << "y" << '=' << y << endl;
  }
};
bool operator!=(TPoint a, TPoint b) { return sgn(a.x - b.x) || sgn(a.y - b.y); }
bool operator==(TPoint a, TPoint b) {
  return !sgn(a.x - b.x) && !sgn(a.y - b.y);
}
bool operator<(TPoint a, TPoint b) {
  return sgn(a.x - b.x) ? sgn(a.x - b.x) == -1 : sgn(a.y - b.y) == -1;
}
TPoint operator-(TPoint a, TPoint b) { return TPoint(a.x - b.x, a.y - b.y); }
TPoint operator+(TPoint a, TPoint b) { return TPoint(a.x + b.x, a.y + b.y); }
TPoint operator*(TPoint a, double b) { return TPoint(a.x * b, a.y * b); }
TPoint operator/(TPoint a, double b) { return TPoint(a.x / b, a.y / b); }
TPoint rot90(TPoint a) { return TPoint(-a.y, a.x); }
double cross(TPoint a, TPoint b) { return (a.x * b.y - a.y * b.x); }
double cross(TPoint a, TPoint b, TPoint c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}
double dot(TPoint a, TPoint b) { return (a.x * b.x + a.y * b.y); }
double dot(TPoint a, TPoint b, TPoint c) {
  return (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y);
}
double len(TPoint a) { return sqrt(a.x * a.x + a.y * a.y); }
double dis(TPoint a, TPoint b) { return len(a - b); }
bool seg_inter(TPoint a, TPoint b, TPoint c, TPoint d) {
  return max(a.x, b.x) >= min(c.x, d.x) && max(c.x, d.x) >= min(a.x, b.x) &&
         max(a.y, b.y) >= min(c.y, d.y) && max(c.y, d.y) >= min(a.y, b.y) &&
         sgn(cross(a, b, c)) * sgn(cross(a, b, d)) < 0 &&
         sgn(cross(c, d, a)) * sgn(cross(c, d, b)) < 0;
}
TPoint get_inter(TPoint a, TPoint b, TPoint c, TPoint d) {
  double s1 = cross(a, b, d), s2 = cross(c, a, b);
  return TPoint((s1 * c.x - s2 * d.x) / (s1 - s2),
                (s1 * c.y - s2 * d.y) / (s1 - s2));
}
bool on_segment(TPoint &c, TPoint &a, TPoint &b) {
  return sgn(cross(c, a, b)) == 0 && dot(c, a, b) < 0;
}
struct Circle {
  TPoint o;
  double r;
  Circle() {}
  Circle(TPoint _o, double _r) : o(_o), r(_r) {}
};
vector<TPoint> Circle_cross(Circle c1, Circle c2) {
  double d = len((c1.o - c2.o));
  vector<TPoint> ret;
  if (sgn(d - (c1.r + c2.r)) == 1 || sgn(d - fabs(c1.r - c2.r)) == -1)
    return ret;
  double d1 = (c1.r * c1.r + d * d - c2.r * c2.r) / 2.0 / d;
  TPoint dir = (c2.o - c1.o) / d, pcrs = c1.o + dir * d1;
  double dt = sqrt(max(0.0, c1.r * c1.r - d1 * d1));
  dir = rot90(dir);
  ret.push_back(pcrs + dir * dt);
  ret.push_back(pcrs - dir * dt);
  return ret;
}
const int maxn = 5005;
char s[maxn];
void gao(char ch, int &c1, int &c2, int &c3) {
  if (ch == '(') c1++;
  if (ch == ')') c2++;
  if (ch == '?') c3++;
}
int main() {
  cin >> s + 1;
  int len = strlen(s + 1);
  int ans = 0;
  for (int l = 1; l < (len + 1); ++l) {
    int mmin = 0, mmax = 0;
    for (int r = l; r < (len + 1); ++r) {
      if (s[r] == '(') mmin++, mmax++;
      if (s[r] == ')') mmin--, mmax--;
      if (s[r] == '?') mmin--, mmax++;
      if (mmax < 0) break;
      mmin = max(mmin, 0);
      if (mmin == 0 && (l - r + 1) % 2 == 0 && s[r] != '(') ans++;
    }
  }
  cout << ans << endl;
}