function main(arg) {
	arg = arg.trim().split(/\n/);
  	var n = arg[0], s = arg[1], abc = /(ABC)/g,
  		out = s.match(abc);
 	if (out === null) {
    	console.log('0');
    } else {
	 	console.log(out.length);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))