program test 
implicit none
integer::n,i,ans
character(len=50)::s
read*,n, s
s=trim(s)
ans=0
do i=1,n-2
	if(s(i:i+2)=='ABC')then
    	ans=ans+1
    else 
    	ans=ans
    end if
end do
print*,ans
end program test
    