fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    val Z = readLine()!!

    val A = 'A'
    val B = 'B'
    val C = 'C'

    var i = 0
    var answer = 0

    if(N < 3){
        println("0")
        return
    }

    while(true){
        if(Z[i] == A && Z[i+1] == B && Z[i+2] == C){
            answer++
            i+=3
        }else{
            i++
        }
        if(i >= N-2)break
    }

    println(answer)
}