import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val s = sc.next + "**"

  val res = s.tail.tail.foldLeft((0, s.head, s.tail.head)){ case ((cnt, pre2, pre), now) =>
    if(pre2 == '*' || pre == '*' || now == '*') (cnt, '*', '*')
    else {
      val newCnt = cnt + ( if ( pre2 == 'A' && pre == 'B' && now == 'C') 1 else 0)
      (newCnt, pre, now)
    }
  }._1

  println(res)
}
