program readABC
implicit none
integer :: N
integer :: i,ans=0
character(50) S

read*,N
read*,S

do i = 1,n-2
    if(s(i:i+2)=='ABC')then
      ans=ans+1
    end if
end do

print*,ans

end program readABC