import java.util.*;
import java.io.*;

public class brackets_al {
  public static void main (String args []) throws Exception {
    BufferedReader in = new BufferedReader (new FileReader ("brackets.in"));
    PrintWriter out = new PrintWriter ("brackets.out");
    String s = in.readLine ();
    if (in.ready ()) throw new Exception ("EOF expected");
    int c1 = 0, c2 = 0, b = 0, bc = 0;
    long ans = 0;
    for (int i = 0; i < s.length (); i++) {
      ++bc;
      if (s.charAt (i) == '(') {
        ++c1;
        ++b;
      } else if (s.charAt (i) == ')') {
        ++c2;
        --b;
        if (b == 0) {
          ans += ((long)(bc - 1)) * bc / 2;
          bc = 0;
        }
        if (b < 0) {
          throw new Exception ("Not a correct sequence");
        }
      } else throw new Exception ("Unexpected character");
    }
    if (b != 0 || c1 != c2) {
      throw new Exception ("Not a correct sequence");
    }
    ans += ((long)(s.length () + 2)) * (s.length () + 1) / 2;
    out.println (ans);
    out.close ();
  }
}