import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readStr() -> [String] {
  let str:String = readLine()!
  let arr:[String] = str.components(separatedBy: " ")
  return arr
}

let nb=readInts()
let n=nb[0]
let strs=readStr()
let S=strs[0]

var ans=0

for i in 0..<n-2{
  let c1=S[S.index(S.startIndex,offsetBy:i)]
  let c2=S[S.index(S.startIndex,offsetBy:i+1)]
  let c3=S[S.index(S.startIndex,offsetBy:i+2)]
  if (c1=="A")&&(c2=="B")&&(c3=="C"){ans+=1}
}

print(ans)