import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)
  val n = sc.nextLine().toInt
  val s = sc.nextLine()

  println(m(0, 0))
  
  def m(i: Int, count: Int): Int = {
    s.indexOf("ABC", i) match {
      case -1 => count
      case ni => m(ni + 1, count + 1)
    }
  }
  
}
