function main (input) {
  let count = 0;
  while(input.indexOf('ABC')>=0){
    let index = input.indexOf('ABC');
    let a = input.replace('ABC','BCA');
    count++;
    console.log(a,a.slice(index))
    input = a.slice(index);
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin','utf8'));