import scala.collection.immutable
object Main extends App {
  import scala.io.StdIn._
  import scala.math._
  val expression = readLine.trim.map(c ⇒ if (c == '(') 1 else -1).toArray
  for (i ← expression.indices.tail) expression(i) += expression(i - 1)
  val indices: Map[Int, immutable.IndexedSeq[Int]] = expression.indices.groupBy(i ⇒ expression(i))
  println(
    indices.map(a ⇒ a._2.length * (a._2.length - 1L) / 2).sum
  )
}
