program main
implicit none
integer i,n,j,n_abc
character(50) s

read(*,*) n
read(*,*) s

n_abc=0
i=1
do while(i<n)
   j=index(s(i:),'ABC')
   if(j==0) exit
   n_abc = n_abc + 1
   i=i+j
end do
write(*,'(i0)') n_abc
end program main