n = int(eval(input()))

s = eval(input())

count = 0

c = "ABC"

for i in range(n-2):

	if s[i:i+3] == c:

		count += 1

print(count)

n = int(eval(input()))

s = eval(input())

count = 0

c = "ABC"

for i in range(n-2):

	if s[i:i+3] == c:

		count += 1

		i += 3

print(count)

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

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

+        i += 3