import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val s = cin.nextLine()

    var on = false
    var on_a_count: Long = 0
    var bc = false
    var ans: Long = 0
    for (i in 0..s.length-1) {
        if (bc) {
            if (s[i] == 'C') {
                ans += on_a_count
                bc = false
                continue
            } else {
                on = false
                bc = false
            }
        }
        if (!on) {
            if (s[i] == 'A') {
                on = true
                on_a_count = 1
            }
        } else {
            if (s[i] == 'A') {
                on_a_count += 1
            } else if (s[i] == 'B') {
                bc = true
            } else {
                on = false
            }
        }
    }
    println(ans)
}