fun main(args : Array<String>) {
    val ss = readLine()!!

    var aCnt = 0
    var ans = 0L
    var found = false

    for (i in 0..ss.length-2) {
        if (found) {
            found = false
            continue
        }

        if (ss[i] == 'A') {
            aCnt++
            continue
        }

        if (aCnt > 0 && ss[i] == 'B' && ss[i+1] == 'C') {
            ans += aCnt
            found = true
            continue
        }

        aCnt = 0
    }

    println(ans)
}