local str = io.read()
-- local str = "AAABCBC"
local index = 1
local tStr = {}
for i = 1, #str do
    tStr[i] = string.sub(str, i, i)
end
local sum = 0
local a = 0
for i = index, #str do
    if tStr[i] == "A" then
        a = a + 1
    elseif not (tStr[i + 1] == "B" and tStr[i + 2] == "C")then
        a = 0
    elseif  tStr[i]  == "B" and  (i + 1 <= #tStr and tStr[i + 1]  == "C") then
        sum = sum + a
        i = i + 1
    end
end
print(sum)
