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:
//package com.company;
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        C(sc, pw);
        pw.close();
    }

    public static void A(MyScanner sc, PrintWriter pw) throws IOException {
        int n = sc.nextInt();
        int[] a = new int[51];
        a[0] = 0;
        a[1] = 1;
        for (int i = 2; i < 51; i++) {
            a[i] = a[i - 1] + a[i - 2];
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            boolean in = false;
            for (int j = 0; j < 51; j++) {
                if (i == a[j]) {
                    in = true;
                    break;
                }
            }
            if (in){
                sb.append('O');
            } else {
                sb.append( 'o');
            }
        }
        pw.println(sb.toString());
    }

    public static void B(MyScanner sc, PrintWriter pw) throws IOException {
        int n = sc.nextInt(); int m = sc.nextInt();
        Map<String, String> map= new HashMap<>();
        for (int i = 0; i < n; i++) {
            String name = sc.next();
            String ip = sc.next();
            map.put(ip, name);
        }
        for (int i = 0; i < m; i++) {
            String q = sc.next();
            String q1 = sc.next();
            pw.println(q + " " + q1 + " #" + map.get(q1.substring(0, q1.length() - 1)));
        }

    }

    public static void C(MyScanner sc, PrintWriter pw) throws IOException {
        String s = sc.next();
        int n = s.length();
        int tot = 0;
        for (int i = 0; i < n; i++) {
            int left = 0;
            int right = 0;
            int qes = 0;
            int sol = 0;
            for (int j = i; j < n; j++) {
                if (s.charAt(j) == '('){
                    left++;
                } else if (s.charAt(j) == ')') {
                    right++;
                } else {
                    right++;
                    qes++;
                }
                if (left < right) {
                    if (qes == 0) break;
                    qes -= 1;
                    right -= 1;
                    left += 1;
                }
                if (left == right){
                    sol++;
                }
            }
            tot += sol;
        }
        pw.println(tot);
    }


    public static void D(MyScanner sc, PrintWriter pw) throws IOException {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] graph = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                graph[i][j] = -1;
            }
        }
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt(), b = sc.nextInt(),c = sc.next().charAt(0);
            graph[a - 1][b - 1] = c - 'a';
        }
        int[][][][] dp = new int[n][n][26][2];//1 for A, -1 for B
        int[][] sol = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                sol[i][j] = solve(graph, dp, n, m, i, j, 0, 0);
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (sol[i][j] == 1){
                    pw.print('A');
                } else if (sol[i][j] == -1){
                    pw.print('B');
                }
            }
            pw.println();
        }
    }
    public static int solve(int[][] graph, int[][][][] dp, int n, int m, int p1, int p2, int mi, int start){
        if (dp[p1][p2][mi][start] != 0) return dp[p1][p2][mi][start];
        if (start == 0){
            int best = 0;
            for (int i = 0; i < n; i++) {
                if (graph[p1][i] >= mi) {
                    best = Math.max(best, solve(graph, dp, n, m, i, p2, graph[p1][i], 1));
                }
            }
            if (best == 0) {
                best = -1;
            }
            return dp[p1][p2][mi][start] = best;
        } else {
            int best = 0;
            for (int i = 0; i < n; i++) {
                if (graph[p2][i] >= mi) {
                    best = Math.min(best, solve(graph, dp, n, m, p1, i, graph[p2][i], 0));
                }
            }
            if (best == 0) {
                best = 1;
            }
            return dp[p1][p2][mi][start] = best;
        }
    }

    public static void E(MyScanner sc, PrintWriter pw) throws IOException {


    }



    static class MyScanner {
        StringTokenizer st;
        BufferedReader br;

        public MyScanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public MyScanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException { return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}