s = gets.chomp
cnt = 0
while true
  ss = s.clone
  ss = ss.gsub(/ABC/,'*')

  while true
    if ss.count('*') > 0
      ss = ss.sub(/\*/,'BCA')
      cnt += 1
    else
      break
    end
  end

  if s == ss
    break
  else
    s = ss.clone
  end
end

puts cnt
