function Main(input) {
	var output = 0;
  if(input.length <= 2){
     console.log(output);
    return;
     }
  while(input.indexOf("ABC") != -1){
        output += input.match(new RegExp("ABC","g")).length;
    input = input.replace(/ABC/g,"BCA"); 
  }
        
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
