s = gets.strip
if s.length < 3
  puts 0
  exit
end

ans = 0
ca = 0
i = 0
while i < s.length - 2
  if s[i, 3] == 'ABC'
    ans += (ca + 1)
    s[i + 2] = 'A'
    i += 2
    next
  else
    if s[i] == 'A'
      ca += 1
    else
      ca = 0
    end
    i += 1
  end
end
puts ans
