n=int(eval(input()))

s=eval(input())+"xxxxxxxx"

ans=chk=0

for i in range(n):

    w=s[i]+s[i+1]+s[i+2]

    if w=="ABC":

        ans+=1

print(ans)

n=int(eval(input()))

s=eval(input())+"XXX"

ans=0

for i in range(n):

    if s[i]+s[i+1]+s[i+2]=="ABC": ans+=1

print(ans)
n = int(eval(input()))
s = eval(input()) + "xxxxxxxx"
ans = chk = 0
for i in range(n):
    w = s[i] + s[i + 1] + s[i + 2]
    if w == "ABC":
        ans += 1
print(ans)

n = int(eval(input()))
s = eval(input()) + "XXX"
ans = 0
for i in range(n):
    if s[i] + s[i + 1] + s[i + 2] == "ABC":
        ans += 1
print(ans)

-s = eval(input()) + "xxxxxxxx" -ans = chk = 0 +s = eval(input()) + "XXX" +ans = 0 -    w = s[i] + s[i + 1] + s[i + 2] -    if w == "ABC": +    if s[i] + s[i + 1] + s[i + 2] == "ABC":