--[[
ABCACCBABCBCAABCB
[1] ABCACCBABCBCABCAB
[2] ABCACCBABCBCBCAAB
[5] ABCACCBBCBCBCAAAB
[6] BCAACCBBCBCBCAAAB

AAABCBC

BCBCAAA

]]
local s = io.read()
local n = #s
local sub = ""
local state = 1
local alen = 0
local ret = 0
for i = 1, n do
  sub = s:sub(i, i)
  if state == 1 then
    if sub == "A" then
      alen = alen + 1
    elseif sub == "B" then
      state = 2
    else
      alen = 0
    end
  elseif state == 2 then
    if sub == "C" then
      ret = ret + alen
    elseif sub == "A" then
      alen = 1
    else
      alen = 0
    end
    state = 1
  end
end
print(ret)
