fun main (args:Array<String>){
    var strLen = readLine()!!.toInt()
    var strS = readLine()!!
    var count = 0

    while(strLen >= 3){
        var abcIndex = strS.indexOf("ABC")
        if(abcIndex == -1){
            break
        }
        else {
            strS = strS.drop((abcIndex + 3))
            count++
            strLen -= abcIndex + 3
        }
    }
    print(count)
}