function Main(input) {
	var output = 0;
  if(input.length <= 2){
     console.log(output);
    return;
     }
  while(true){
        var breakFlag = true;
  for(var i = 0; i < input.length; i++){
    var a = input.slice(i , i + 1);
    var b = input.slice(i + 1, i + 2);
    var c = input.slice(i + 2, i + 3);
    if(a == "A" && b == "B" && c == "C"){
       output++;
       i = i + 2;
       breakFlag = false;
    }
  }
    if(breakFlag){
       break;
       }else{
         //console.log(output);
        input = input.replace(/ABC/g,"BCA"); 
       }
  }
  console.log(output);
}

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