S=gets.chomp

state = 0
acount = 0
ret = 0

S.each_char do |c|
#  p [c, state, acount,ret]
  case state
  when 0
    if c == 'A'
      acount += 1
      state = 1
    else
      acount = 0
    end
  when 1
    if c == 'A'
      acount += 1
    elsif c == 'B'
      state = 2
    else
      acount = 0
      state = 0
    end
  when 2
    if c == 'C'
      ret += acount
      state = 1
    else
      acount = 0
      state = 0
    end
  end
end

p ret
