n = int(eval(input()))

s = eval(input())



ans = 0

for i in range(n-2):

    if s[i:i+3] == "ABC":

        ans += 1



print(ans)

n = int(eval(input()))

*s, = eval(input())



ans = 0

for i in range(n-2):

    if "".join(s[i:i+3]) == "ABC":

        ans += 1



print(ans)

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

n = int(eval(input()))
(*s,) = eval(input())
ans = 0
for i in range(n - 2):
    if "".join(s[i : i + 3]) == "ABC":
        ans += 1
print(ans)

-s = eval(input()) +(*s,) = eval(input()) -    if s[i : i + 3] == "ABC": +    if "".join(s[i : i + 3]) == "ABC":