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 JAVA):

Solution:
import java.util.*;
import java.io.*;
import java.math.*;

public class a {


    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        char[] str = in.next().toCharArray();
        int n = str.length;
        long count = 0;
        for (int si = 0; si < n; si++) {
        	long amt = 0;
        	long one = 0;
        	long two = 0;
        	long sign = 1;
        	long add = 0;
        	for (int i = si; i < n; i++) {
        		sign = 1 - sign;
        		if (str[i] == '?') {
        			if (amt > 0) {
        				amt--;
        				two++;
        			} else {
        				one++;
        			}
        		} else if (str[i] == '(') {
        			amt++;
        		} else {
        			if (amt > 0) {
        				amt--;
        			} else if (one > 0) {
        				one--;
        			} else if (two > 0) {
        				two--;
        				amt++;
        			} else {
        				break;
        			}
        		}
        		if (sign == 1) {
        			
        			if (amt == 0)
        				count++;
        		}
        	}
        }
        System.out.println(count);
        
        
        
        
        
        out.close();
    }


    static Random rand = new Random();
    static void sort(int[] a) {
        lsbRadixSort(a, true);
    }
    static void sort(long[] a) {
        int n = a.length;
        for (int i = a.length - 1; i > 0; i--) {
            int j = rand.nextInt(i + 1);
            long tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }
    static void sort(double[] a) {
        int n = a.length;
        for (int i = a.length - 1; i > 0; i--) {
            int j = rand.nextInt(i + 1);
            double tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }
    static void lsbRadixSort(int[] a, boolean signed) {
        int s = 0, n = a.length;
        int[] p = new int[257], b = new int[n];
        int sb = 1 << 31;
        if(signed) for(int i=0;i<n;i++)  a[i] ^= sb;
        while (s < 32) {
            Arrays.fill(p, 0);
            for (int i = 0; i < n; i++)
                p[((a[i] >>> s) & 255)+1]++;
            for(int i=2;i<256;i++)
                p[i] += p[i-1];
            for (int i = 0; i < n; i++)
                b[p[(a[i] >>> s) & 255]++] = a[i];
            int[] tmp = b;  b = a;  a = tmp;
            s += 8;
        }
        if(signed) for(int i=0;i<n;i++)  a[i] ^= sb;
    }
    static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    static long[] eEuclid(long a, long b) {
        if (b == 0) return new long[] { a, 1, 0 };
        long[] ans = eEuclid(b, a % b);
        long temp = ans[1] - ans[2] * (a / b);
        ans[1] = ans[2];  ans[2] = temp;
        return ans;
    }
    static long modInverse(long a, long m) {
        return ((eEuclid(a, m)[1] % m) + m) % m;
    }
    static class IntList {
        static int[] EMPTY = {};
        int[] a = EMPTY;
        int n = 0;
        void add(int v) {
            if (n >= a.length)
                a = Arrays.copyOf(a, (n << 2) + 8);
            a[n++] = v;
        }
        int get(int idx) {
            return a[idx];
        }
        int size() {
            return n;
        }
    }
    static class DisjointSet {
        int[] s;
	
        public DisjointSet(int n) {
            Arrays.fill(s = new int[n], -1);
        }	
        public int find(int i) {
            return s[i] < 0 ? i : (s[i] = find(s[i]));
        }	
        public boolean union(int a, int b) {
            if ((a = find(a)) == (b = find(b))) return false;
            if(s[a] == s[b]) s[a]--;
            if(s[a] <= s[b]) s[b] = a; else s[a] = b;
            return true;
        }
    }
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if(st.hasMoreTokens())
                return st.nextToken();
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
        public int[] nextOffsetIntArray(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextInt() - 1;
            return arr;
        }
        public int[] nextIntArray(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextInt();
            return arr;
        }
        public int[][] nextIntArray(int n, int m) throws IOException {
            int[][] arr = new int[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextInt();
            return arr;
        }
        public long[] nextLongArray(int n) throws IOException {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextLong();
            return arr;
        }
        public long[][] nextLongArray(int n, int m) throws IOException {
            long[][] arr = new long[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextLong();
            return arr;
        }
        public double[] nextDoubleArray(int n) throws IOException {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextDouble();
            return arr;
        }
        public double[][] nextDoubleArray(int n, int m) throws IOException {
            double[][] arr = new double[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextDouble();
            return arr;
        }
        public char[][] nextCharArray(int n, int m) throws IOException {
            char[][] arr = new char[n][];
            for (int i = 0; i < n; i++)
                arr[i] = next().toCharArray();
            return arr;
        }
    }
}