import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val s = sc.nextLine()
    val ss = s.replaceAll("BC", "D")
    var countA = 0L
    var ans = 0L

    var flag = true

    for (i <- 0 until ss.length) {
      if (flag) {
        ss(i) match {
          case 'A' => countA += 1
          case 'D' => ans += countA
          case _ => countA = 0
        }
      }
    }

    println(ans)
  }
}