function Main(input) {
	var output = 0;
  if(input.length <= 2){
     console.log(output);
    return;
     }
  var renzoku = 0;
  for(var i = 0; i < input.length + 1; i++){
    var a = input.slice(i , i + 1);
    var b = input.slice(i + 1, i + 2);
    var c = input.slice(i + 2, i + 3);
    var tmp = input.slice(i + 3, i + 4);
    //console.log(a+b+c);
    if(a + b + c == "ABC"){
       renzoku++;
      i = i + 2;
    }else if(a + b + c != "ABC" || tmp == null) {
      //console.log(renzoku);
       output += getValue(renzoku);
      renzoku = 0;
    }
    
  }
        
  console.log(output);
  
  function getValue(val){
    var ret = 0;
    for(var i = 1; i <= val; i++){
      ret += i;
    }
    return ret;
  }
}

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