import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
    Main() { super(System.out, true); }
    Scanner sc = new Scanner(System.in);
    public static void main(String[] $) {
        Main o = new Main(); o.main(); o.flush();
    }

    void main(){
        int N = sc.nextInt();
        if(N > 50){
            N = 50;
        }
        String S = sc.next();
        int Y = 0;
        int U = 0;
        for(int i = 0; i < N;i++){
            if(Y == 0){
                if(S.charAt(i) == 'A'){
                    Y = 1;
                }
            }
            else if(Y == 1){
                if(S.charAt(i) == 'B'){
                    Y = 2;
                }
                else if(S.charAt(i) == 'A'){
                    Y = 1;
                }
                else{
                    Y = 0;
                }
            }
            else if(Y == 2){
                if(S.charAt(i) == 'C'){
                    Y = 0;
                    U++;
                }
                else if(S.charAt(i) == 'C'){
                    Y = 1;
                }
                else{
                    Y = 0;
                }
            }
        }
        print(U);
    }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz