fun main(args: Array<String>) {
    val s = readInputLine().replace("BC", "D").toCharArray()
    
    var Acnt = 0L
    var ans = 0L

    for (i in 0 until s.size) {
        when (s[i]) {
            'A' -> Acnt++
            'D' -> ans += Acnt
            else -> Acnt = 0L
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}
