function main(input) {
    var value = input.trim();
    var index;
    var count = 0;
    while((index = value.indexOf("ABC")) !== -1) {
        var arr = value.split("ABC");
        count += arr.length - 2
        value = arr.join("BCA")
        count++;
    }

    console.log(count)
}

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