program count_abc
  implicit none
  integer :: n, i, m = 0
  character(50) :: s
  read(*,*) n
  read(*,*) s
  do i = 1, n-2
    if (s(i:i+2) == "ABC") m = m+1
  end do
  write(*,'(i0)') m
end program count_abc