program ABC150B
    implicit none
    integer(8)::N,i
    integer(8)::result=0
    character(50)::S
    read(5,*)N
    read(5,*)S

    do i=1,N-2
        if(S(i:i+2)=="ABC")then
            result=result+1
        end if
    end do

    print'(i0)',result
end program ABC150B