program count_abc
    implicit none
    character(50):: s
    integer(4):: n, i, c

    read*, n
    read*, s
    c=0
    do i=1, len_trim(s)-2
        if (s(i:i+2) == 'ABC') c=c+1
    end do
    print*, c
end program count_abc