var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var S = lines[0].split("");
    var ans = 0;

    for (var i = 0; i < S.length; i++) {
        if (S[i] === "A" && S[i + 1] === "B" && S[i + 2] === "C") {
            S[i] = "B"; S[i + 1] = "C"; S[i + 2] = "A"
            ans++; i += 2;
        }
    }
    var before = ans;

    for (var i = 0; i < S.length; i++) {
        if (S[i] === "A" && S[i + 1] === "B" && S[i + 2] === "C") {
            S[i] = "B"; S[i + 1] = "C"; S[i + 2] = "A"
            ans++; i += 2
        }
    }
    if (before === ans) { console.log(ans); return (0); }

    for (var i = 0; i < S.length; i++) {
        if (S[i] === "A" && S[i + 1] === "B" && S[i + 2] === "C") { ans++; }
    }

    console.log(ans);
});