program main
      implicit none
      integer :: n, i, cnt
      character(50) :: s

      read *, n
      read *, s

      cnt = 0
      do i = 1, n
        if( s(i:i) == 'A' ) then
          if( s(i+1:i+1) == 'B' ) then
            if ( s(i+2:i+2) == 'C' ) then
              cnt = cnt + 1
            else
            end if
          else
          end if
        end if
      end do
      print *, cnt

end program main
