s = gets.chomp

result = 0

# AA...ABCの形を探す
i = 0
a_count = 0
a_flag = false
while i < s.length do
  if a_flag
    if s[i] == "A"
      a_count += 1
      i += 1
    elsif s[i] == "B" && s[i+1] == "C"
      result += a_count
      i += 2
    else
      a_count = 0
      a_flag = false
      i += 1
    end
  else
    if s[i] == "A"
      a_count = 1
      a_flag = true
      i += 1
    else
      i += 1
    end
  end
end

puts result
