fun main(args: Array<String>) {
  val sRaw = readLine()!!
  val n = sRaw.length
  val s = sRaw + "$$$"
  var from = 0
  var ans = 0L
  while (from < n) {
    if (s[from] != 'A') {
      from++
      continue
    }
    var inclusiveTo = from
    while (true) {
      if (s[inclusiveTo + 1] == 'A') {
        inclusiveTo++
        continue
      } else if (s[inclusiveTo + 1] == 'B' && s[inclusiveTo + 2] == 'C') {
        inclusiveTo += 2
        continue
      }
      break
    }
    // println("$from $inclusiveTo")
    val aIndexSum = (from..inclusiveTo).filter { s[it] == 'A' }.map { it.toLong() }.sum()
    val aCount = (from..inclusiveTo).count { s[it] == 'A' }
    val aIndexSumAfter = ((inclusiveTo - aCount + 1)..inclusiveTo).map { it.toLong() }.sum()
    ans += (aIndexSumAfter - aIndexSum) / 2
    from = inclusiveTo + 1
  }
  println(ans)
}