maps = gets
maps.gsub!(/BC/,"X")
maps.gsub!(/C/,"Y")
maps.gsub!(/B/,"Y")
maps.gsub!(/Y+/,"Y")
maps.chomp!

maps = maps.split("Y")
ans = 0
a_num = 0
maps.each do|unit|
  unit.split("").each_with_index do|item,idx|
    if item == "X"
      ans += a_num
    else
      a_num += 1
    end
  end
  a_num = 0
end

puts ans.to_s