fun main(args: Array<String>) {
    agc034b()
}

fun agc034b() {
    val s = readLine()!!

    var answer = 0L
    var left = 0
    while (left < s.lastIndex) {
        var right = left + 1
        if (s[left] == 'A') {
            var aCount = 1L
            while (right < s.lastIndex) {
                if (s[right] == 'A') {
                    right++
                    aCount++
                } else if (s[right] == 'B' && s[right + 1] == 'C') {
                    right += 2
                    answer += aCount
                } else {
                    break
                }
            }
        }
        left = right
    }

    println(answer)
}
