N = int(eval(input()))

S = eval(input())



answer = 0

for i in range(N-2):

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

    answer += 1



print(answer)
N = int(eval(input()))

S = eval(input())



answer = 0

for i in range(N):

  if i + 3 > N:

    break

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

    answer += 1



print(answer)
N = int(eval(input()))
S = eval(input())
answer = 0
for i in range(N - 2):
    if S[i : i + 3] == "ABC":
        answer += 1
print(answer)

N = int(eval(input()))
S = eval(input())
answer = 0
for i in range(N):
    if i + 3 > N:
        break
    if S[i : i + 3] == "ABC":
        answer += 1
print(answer)

-for i in range(N - 2): +for i in range(N): +    if i + 3 > N: +        break