fun main(args: Array<String>) {
    val s = readLine()!!.replace("BC","X")
    var countA = 0
    var ans = 0L
    s.forEach {
        when(it){
            'A' -> countA++
            'X' -> ans+=countA
            else -> countA=0
        }
    }
    println(ans)
}