function Main(input) {
  input.trim();
 input = input.split("\n");
 var arr = input[1].split("");
 var N = input[0];
 var point = 0;
 var ans = 0;
 for(var i=0;i<N;i++){
   switch(point){
     case 0:
     if(arr[i]=="A"){
       point++
     }
     break;
     case 1:
     if(arr[i]=="B"){
       point++
     }else{
       point = 0;
     }
     break;
     case 2:
     if(arr[i]=="C"){
       ans++;
     }
     point = 0;
     break;
   }
 }
 console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));