n = int(eval(input()))

s = eval(input())



string = 'ABC'

count = 0





for i in range(n - 2):

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

        count += 1



        

print(count)
n = int(eval(input()))

s = eval(input())

l = 'ABC'

count = 0



for i in range(n-2):

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

        count += 1

        

        

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

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

-string = "ABC" +l = "ABC" -    if s[i : i + 3] == string: +    if s[i : i + 3] == l: