program answer
  implicit none

  character(len=50) :: S
  integer :: i, N, count

  read(*,*) N
  read(*,*) S

  count = 0
  do i = 1, N-2
     if(S(i:i+2)=='ABC') then
        count = count + 1
     end if
  end do

  write(*,*) count
  stop
 end program answer
