peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
s = input()
ans = 0
for i in range(n - 2):
  if s[i:i + 3] == "ABC":
    ++ans
print(ans)
N = input() # Do Not use
S = input()
print(S.find("ABC"))
n=int(input())
s=input()
j=0
count=0
for i in range(n):
    u=s[i:i+1]
    #print(u)
    if j==0 and u=="A":
        j=1
    elif j==0 and u!="A":
        j=0
    elif j==1 and u=="B":
        j=2
    elif j==1 and u!="B":
        j=0
    elif j==2 and u=="C":
        j=0
        count+=1
    elif j==2 and u!="C":
        j=0
print(count)
n = int(input())
s = str(input())
cnt = 0

for i in range(n-3):
    if s[i] == "A":
        if s[i+1] == "B":
            if s[i+2] == "C":
                cnt += 1
print(cnt)
N = int(input())
S = input()
ans = 0
for i in range(N-3):
    if S[i:i+3] == 'ABC':
        ans += 1
print(ans)
N = int(input())
S = input()
cnt = 0
for i in range(N-3):
    if S[i:i+3] == "ABC":
        cnt +=1
print(cnt)
n = int(input())
s = list(str(input()))
ans = s.count('ABC')
print(ans)
# 初期入力
N =int(input())
S = input()

ABC_count = 0
for i in range(N-3):
    if S[i:i+3] =="ABC":
        ABC_count += 1
    
print(ABC_count)
num = int(input())
word = input()
if len(word) >= num:
    print(word[0:num].count('ABC'))
print(0)
n=input()
s=raw_input().strip()
ans=0
for i in xrange(n-2):
  if s[i:i+2]=='ABC': ans+=1
print ans
n = int(input()); s = input() ; c = 0

for i in range(n):
    a = s[i-3:i]

    if a == 'ABC':
        c += 1
print(c)
input = input()
result = 0
for i in range(len(input) - 2):
    serach = input[i:i+3]
    if serach == "ABC":
        result += 1
print(result)
n = int(input())
s = input()
cnt = 0
for i in range(n - 3):
    if s[i:i + 3] == 'ABC':
        cnt += 1
print(cnt)
N = int(input())
S = input()

i = 0
ans = 0
for i in range(N-3):
    if S[i] == "A" and S[i + 1] == "B" and S[i+2] == "C":
        ans += 1

print(ans)
import numpy as np

def main():
    N = int(input())
    S = input()

    flag = 0
    ans = 0
    for s in S:
        if (s == "A") & (flag == 0):
            flag = 1
        elif (s == "B") & (flag == 1):
            flag = 2
        elif (s == "C") & (flag == 2):
            flag = 3
            ans += 1
        else:
            flag = 0
    print(ans)

    return 0

if __name__ == '__main__':
    main()
def solve():
    n = int(input())
    s = input()
    state = 0
    count = 0
    for c in s:
        if c == 'A':
            state += 1
            continue
        elif state == 1 and c == 'B':
            state += 1
            continue
        elif state == 2 and c == 'C':
            count += 1
        state = 0

    print(count)

if __name__ == '__main__':
    solve()
n = int(input())
s = input()
ans = 0
for i in range(len(s)-3):
    if s[i:i+3] == "ABC":
        ans+=1
print(ans)
N=int(input())
S=input()
ans=0
for i in range(N-3):
  if "ABC"==S[i:i+3]:
    ans+=1
print(ans)
s1=input()

count=0
for i in range ((len(s1))-2):
    if(s1[i]=='A' and s1[i+1]=='B' and s1[i+2]=='C'):
        count=count+1
    
print(count)
N = int(input())
S = input()

count = 0
for i in range(N-3):
	if S[i:i + 3] == "ABC":
		count = count + 1
print(count)
N = int(input())
S = str(input())
p = "abc"
print(S.count("abc"))
N = int(input())
S = input()
count = 0
hit = 0
for s in S:
    if s == 'A' and hit == 0:
        hit += 1
    elif s == 'B' and hit == 1:
        hit += 1
    elif s == 'C' and hit == 2:
        count += 1
        hit = 0
    else:
        hit = 0
print(count)
N = int(input())
S = input()
c = 0
for i in range(N-2):
  S[i] + S[i+1] + S[i+2] == 'ABC'
  c += 1
print(c)
n = input()
s = input()
prev = ""
cnt = 0
flag = False
for i in s:
    if flag:
        if i == "C" and prev == "B":
            cnt += 1
            flag = False
    elif i == "A":
        flag = True
    prev = i

print(cnt)
Input = int(input())
N = Input
Input =str(input())
ar = list(Input)



chk = 0
cnt = 0
for i in range(N):
  if chk == 0:
    if ar[i]=='A':
      chk+=1
  elif chk == 1:
    if ar[i]=='B':
      chk+=1
  elif chk == 2:
    if ar[i]=='C':
      chk=0
      cnt+=1

print(cnt)
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    s=input()
    cnt=0
    for i in range(n-3):
        if s[i:i+3]=='ABC':
            cnt+=1
    print(cnt)
resolve()
n =int(input())
s =list(input())
k =0
for i in range(n-3):
    if s[i]=="A":
        if s[i+1]=="B" and s[i+2]=="C":
            k+=1
print(k)
n = int(input())
s = input()
x = list(s)
y = 0
a = 0
while y <= n - 3:
  z = x[y] + x[y + 1] + x[y + 2]
  if z == "abc":
    a += 1
    y += 1
  else:
    a += 0
    y += 1

print(a)
n = int(input())
s = input()
c = 0
for i in range(n-1):
  if s[i]=="a" and s[i+1]=="b" and s[i+2]=="c":
    c += 1
print(c)
N = input()
S = input()

c = 0
s = 0
for k in S:
    if s == 0 and k == "A":
        s = 1
    elif s == 1 and k == "B":
        s = 2
    elif s == 2 and k == "C":
        c += 1
        s = 0
    else:
        s = 0
print(c)
s = input()
N = len(s)
ans = 0
if N < 3:print(0);exit()
i = 0
while i < N-3:
  if s[i:i+3] == 'ABC':ans += 1;i += 3
  else:i+=1

print(ans)
N = input()
S = input()

count = 0
s = "_"
for i in range(len(S)):
    if(S[i]=="A" and s=="_"):
        s = "A"
    if(s=="A" and S[i]=="B"):
        s = "B"
    if(s=="B" and S[i]=="C"):
        s = "_"
        count += 1
print(count)
N=int(input())
S=input()
 
nabc=0
for i in range(0,N-2):
  if S[i:i+2]=='ABC':
    nabc+=1
 
print(nabc)
n = int(input())
s = input()

query = 'ABC'
ans = 0
i = 0 
while i<n:
  i = s.find(query,i)
  print(i)
  if i>=0:
    ans +=1
    i+=1
  else:
    break    

print(ans)
N=int(input())
S=input()
ANS=0
for i in range(N-3):
  if S[i:i+3] == "ABC":
    ANS+=1
print(ANS)
n = int(input())
S = input()
A = 0
for i in range(n-3):
  clipped_S = S[i:i+3]
  if clipped_S == "ABC":
    A += 1
print(A)
N = int(input())
S = input()
ans = 0
for i in range(N - 2):
    if S[i] == "A" and [i + 1] == "B" and S[i + 2] == "C":
        ans += 1
print(ans)
N = int(input())
s = input()
ans = 0
if N < 3:print(0);exit()
for i in range(N-3):
  if s[i:i+3] == 'ABC':ans += 1

print(ans)
n = int(input())
s = input()
count = 0
for i in range(n-3):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        count+=1
print(count)
n = int(input())
s = input()

ans = 0
for i in range(n - 3):
    if s[i:i+3] == 'ABC':
        ans += 1
print(ans)
txt = input().split("A")
n = 0
for cnt in txt:
  if cnt == "ABC":
    n += 1
print(n)
n = int(input())
s = input()
ans = 0
for i in range(n-3):
    if s[i]=="A":
        if s[i+1]=="B":
            if s[i+2]=="C":
                ans += 1
print(ans)
n = int(input())
s = input()

a = s.replace('ABC','1')

b = n - len(a)

print(b/2)
N = int(input())
S = str(input())

count = 0

if len(S) <= 2:
        print('0')
        exit(0)
elif len(S) == 3:
        if 'ABC' in S:
                print('1')
                exit(0)
else:
        for i in range(len(S)-3):
                if 'ABC' in S[i:i+3]:
                        count += 1

print(count)
n = int(input())
s = input()
 
ans = 0
for i in range(n-2):
    if s[i:i+2] == 'ABC':
        ans += 1
 
print(ans)
def resolve():
    _, S = [input() for i in range(2)]

    print(S.count('abc'))


if __name__ == "__main__":
    resolve()
def main():
	sum = 0
	order = 0
	n = input()
	inp = input()
	for c in inp:
		if ord(c) == ord('A') + order:
			if order == 2:
				sum += 1
				order = 0
			else:
				order += 1
		else:
			order = 0
	print(sum)

if __name__ == '__main__':
	main()
N = int(input())
S = input()
tmp_c = 0
count = 0
for i in range(N):
    if tmp_c == 0 and S[i]=="A":
        tmp_c = tmp_c + 1
    elif tmp_c == 1 and S[i]=="B":
        tmp_c = tmp_c + 1
    elif tmp_c == 1:
        tmp_c = 0
    elif tmp_c == 2 and S[i]=="C":
        count = count + 1
        tmp_c = 0
    elif tmp_c == 2:
        tmp_c = 0
print(count)
n = int(input())
s = input()

ans = 0
for i in range(n-3):
    temp = s[i:i+3]
    if(temp == 'ABC'):
        ans += 1

print(ans)
l=input()
cnt=0
for i in range(len(l)-2):
    if l[i]+l[i+1]+l[i+2]=="ABC":
        cnt+=1
print(cnt)
N = int(input("Enter N: "))
S = input("Enter S: ")
print(len(S.split("ABC"))-1)
n=int(input())
count=0
s=input()
for i in s:
  if i=="ABC":
    count+=1  
print(count)
import collections

n = int(raw_input())
s = map(lambda x:ord(x) - ord('a'.upper()),list(raw_input()))

count,c = 0,0
for i in s:
	if i == c:
		c +=1
	else:
		c = 0

	if c == 2:
		count +=1
		c = 0
print count
N = int(input())
S = input()

cnt = 0
for i in range(N):
    print(S[i:i+3])
    if S[i:i+3] == 'ABC':
        cnt += 1

print(cnt)
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s[i:j] == 'ABC':
            ans += 1
print(ans)
N=int(input())
s=input()
cnt=0
for i in range(0,N-3):
  if s[i]+s[i+1]+s[i+2]=="abc":
    cnt+=1
print(cnt)
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, S: str):
    count = 0
    for i in range(N-3):
        if S[i:i+3] == "ABC":
            count += 1
    print(count)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()
n=int(input())
S=input()
L=''
ans=0
for s in S:
    if s=='A' and L=='':
        L += s
    elif s=='B' and L=='A':
        L += s
    elif s=='C' and L=='AB':
        ans += 1
        L='' 
    else:
        L=''
print(ans)
N = int(input())
S = input()

stackString = ""
resultCount = 0
for s in S:
    if stackString == "" and s == "A":
        stackString += "a"
    elif stackString == "a" and s == "B":
        stackString += "b"
    elif stackString == "ab" and s == "C":
        stackString = ""
        resultCount += 1
    else:
        stackString = ""
print(resultCount)
n = int(input())
s = input()

cnt = 0
tmp = ""
for elem in s:
  if "A" == elem:
    tmp += elem
  elif "B" == elem and tmp != "":
    if tmp[-1] == "A":
	    tmp += elem
  elif "C" == elem and tmp != "":
    if tmp[-1] == "B":
    	cnt += 1
    	tmp = ""
print(cnt)
N = int(input())
S = input()
count=0
flag =0

if N>=3 and N<=50:
    if len(S) == N:
        for i in S:
            if i == 'A':
                count+=1
            elif i == 'B' and count == 1:
                count+=1
            elif i == 'C' and count == 2:
                flag+=1
                count=0
            else:
                count=0
print(flag)
n=int(input())
s=input()
count=0
if n==3:
    if s=="ABC":
        count=1
else:
    s=list(s)
    for i in range(n-3):
        if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
            count+=1
print(count)
N = int(input())
S = input()

cnt = 0
ans = 0
for i in S:
	if S[cnt:cnt+3] == "ABC":
		ans += 1
	cnt += 1
	if cnt == (N - 3):
		break
print(ans)
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


n = I()
s = S()
# print(s.count('ABC'))
ans = 0
for i in range(len(s)-3):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
        ans += 1
print(ans)
n = int(input()); s = input() ; c = 0

for i in range(n):
    a = s[i-3:i]
    print(a)
    if a == 'ABC':
        c += 1
print(c)
def main(N,S):
    N = int(N)
    S = str(S)

    c = 0
    for i in range(N-3):
        if S[i:i+2] == 'ABC':
            c = c + 1

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    print(main(N,S))
n = int(input())
s = input()
count = 0
for i in range(n-2):
  print(s[i:i+3])
  if s[i:i+3] == "ABC":
    count += 1
print(count)
_ = input()
s = input()

check = ['A', 'B', 'C']

count = 0
state = 0

for i in range(len(s)):
    c = s[i]
    if c != check[state]:
        state = 0
        continue
    
    state += 1
    if state == 3:
        count += 1
        state = 0

print(count)
def main(N,S):
    N = int(N)
    S = str(S)

    c = 0
    for i in range(N-3):
        if S[i:i+2] == 'ABC':
            c += 1

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    main(N,S)
n = int(input())
s = str(input())

k = s*n
print(k.count('ABC'))
n = int(input())
li = input().split()
cnt = 0
for i in range(len(li) - 3):
    if li[i] == "A" and li[i+1] == "B" and li[i+2] == "C":
        cnt += 1
    else:
        pass
print(cnt)
from sys import stdin

a = stdin.readline().rstrip()
b = stdin.readline().rstrip()

c = 0
cnt = 0
abc = ['A','B','C']
for i in b:
    if i == abc[c]:
        c += 1
        if c ==3:
            c = 0
            cnt += 1
    else:
        c = 0



print(cnt)
N = int(input())
S = input()
length = len(S)
num = 0
print(length)
for i in range(length-2) :
  if S[i:i+3] == "ABC" :
    num += 1
print(num)
n = int(input())
s = input()
cnt = 0
flag = 0
for i in range(n):
  if s[i] == "A":
    flag = 1
  elif s[i] == "B" and flag == 1:
    flag = 2
  elif s[i] == "C" and flag == 2:
    cnt += 1
    flag = 0
print(cnt)
N = int(input())
S = input()

count = 0
for i in range(0,N-3):
    if S[i]=='A':
        if S[i+1]=='B':
            if S[i+2]=='C':
                count += 1
print(count)
N = int(input())
S = input()

K = 'ABC'

idx = 0
cnt = 0

for i in S:
    if i == K[idx]:
        if idx == 2:
            cnt += 1
            idx = 0
        else:
            idx += 1
    else:
        idx = 0

print(cnt)
N = int(input())
S = input()
ans = 0
for i in range(N-3):
    if S[i:i+3] == 'ABC':
       ans += 1 
print(ans)
n=int(input())
s=input()

ans=0
for i in range(n-3):
    if s[i:i+3]=='ABC':
        ans+=1

print(ans)
n=int(input())
s=str(input())
count=0
for i in range(n-3):
    if s[i:i+3] =='ABC':
        count+=1
print(count)
n = int(input())
s = input()
ans = 0
for i in range(n-3):
  if s[i:i+3] == 'ABC':
    ans += 1
print(ans)
n = int(input())
s = input()
ans = 0
for i in range(n - 3):
    if s[i:i + 3] == "ABC":
        ans += 1
print(ans)
n=int(input())
s=input()
c=0
for  i in range(n-3):
    if s[i:i+3]=="ABC":
        c+=1
print(c)
def main():
    N = int(input())
    S = str(input())
    print (S)
    if 'ABC' in S :
        C = S.split('ABC')
        #print (C)
        print (len(C)-1)


if __name__ == '__main__':
    main()
n = int(input())
s = input()      
pattern = list('ABC')          
cnt = 0
match = True

for i in range(n-len(pattern)):
    if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]):
        cnt += 1
print(cnt)
n = int(input())
s = input()
cnt = 0
for i in range(n - 3):
    if s[i:i+3] == "ABC":
        cnt += 1
print(cnt)
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
	count = 0
	num = int(input())
	strings = input()
	print(len(strings))
	for i in range(0,num-2,1):
		if strings[i] == "A" and strings[i+1] == "B" and strings[i+2] == "C":	
			count += 1
	print(count)

if __name__ == '__main__':
	main()
N=int(input())
S=str(input())
count=0

for i in range(N-3):
  if S[i]+S[i+1]+S[i+2]=='ABC':
    count+=1
    
print(count)
a = [input() for i in range(2)]
a[0] = int(a[0])
print(int(a[1].find("ABC")))
N = int(input())
S = input()
ans = 0
if N > 3:
  for i in range(N-3):
    if S[i:i+3] == "ABC":
      ans += 1
else:
  ans = 1 if S == "ABC" else 0
print(ans)
N=int(input())
S=input()
count=0
count_abc=0

for i in range(len(S)):
  if count_abc==0 and S[i]=='A':
    count_abc+=1
  elif count_abc==1 and S[i]=='B':
    count_abc+=1
  elif count_abc==2 and S[i]=='C':
    count_abc=0
    count+=1
  else:
    count_abc=0

print(count)
def main():
  N = int(input())
  S = str(input())
  l = 0
  ans = 0
  for i in range(N):
      if S[i] == 'A':
          l += 1
      elif S[i] == 'B' and l == 1:
          l += 1
      elif S[i] == 'C' and l == 2:
          ans += 1
          l = 0
      else:
          l = 0
  print(ans)
main()
N=int(input())
S=input()
ans=0
for i in range(N-3):
    if S[i:i+3]=='ABC':
        ans+=1
print(ans)
N = input()
S = input("Enter String")
count = 0
for i in range(1, int(N)-1):
    if S[i-1]+S[i]+S[i+1] == "ABC":
        count += 1
print(count)
n=int(input())
t=input()
ans=0
tmp=""
for i in t:
  if i=="A":
    if tmp=="":
    	tmp+="A"
    else:
      	tmp=""
  elif i=="B":
    if tmp=="A":
      tmp+="B"
    else:
      tmp=""
  elif i=="C":
    if tmp=="AB":
      ans+=1
      tmp=""
    else:
      tmp=""
  else:
    tmp=""
print(ans)
n = int(input())
s = input()
c=0
for i in range(n - 2):
    print(s[i:i + 3])
    if s[i:i + 3] == 'ABC':
        c += 1
print(c)
_ = input()
S = input()
newS = S.replace("ABC", "")
print(S, newS)
print((len(S) - len(newS)) // 3)
N = int(input())
S = input()

cnt = 0
for i in range(N - 3):
    if S[i:i + 3] == "ABC":
        cnt += 1

print(cnt)
n=int(input())
s=str(input())
ans=0
for i in range(n):
    if s[i:i+3] =="abc":
        ans +=1
    else:
        ans +=0
print(ans)
n = input()
inp = input()

sum = 0
order = 0

for c in inp:
  if ord(c) == ord('A'):
    order = 1
  elif ord(c) == ord('A') + order:
    order = (order + 1) % 3
    sum += max(0, order - 1)
  else:
    order = 0
print(sum)
n=int(input())
s=input()
s.split('ABC')
print(len(s)-1)
N = int(input())
S = input()
count = 0
if N == 3:
    if S == "ABC":
        print(1)
    else:
        print(0)
    quit()
for i in range(0,N-3):
    if S[i:i+3] == "ABC": count += 1
print(count)
n = int(input())
s = list(input())

p = 0
res = 0

for e in s:
    if p == 0 and e == 'A':
        p += 1
    elif p == 1 and e == 'B':
        p += 1
    elif p == 2 and e == 'C':
        p = 0
        res += 1
    else:
        p = 0
print(res)
if __name__ == '__main__':
    # We have a string S of length N consisting of uppercase English letters.
    n = input()
    s = input()
    num = 0
    if 'ABC' in s:
        num += 1
        s = s.replace('ABC', '')
    print(num)
from sys import stdin

a = stdin.readline().rstrip()
b = stdin.readline().rstrip()

c = 0
cnt = 0
abc = ['A','B','C']
for i in b:
    if i == abc[c]:
        c += 1
    else:
        if c != 0 and abc[c-1] == i:
            c +=1
        else:
            c = 0

    if c == 3:
        c = 0
        cnt += 1

print(cnt)
n = int(input())
s = input()
c = 0
for i in range(n):
  if s[i:i+2] == "c":
    c += 1
print(c)
N = int(input())
S = input()

ans = 0

for i in range(N-3):
    if S[i:i+3]=="ABC":
        ans += 1

print(ans)
sum = 0
order = 0
n = input()
inp = input()
for c in inp:
	if ord(c) == ord('A') + order:
		if order == 2:
			sum += 1
			order = 0
		else:
			order += 1
	else:
		order = 0
print(sum)
N = int(input())
S = input()
"""
10
ZABCDBABCQ
"""

num = 0
for i in range(len(S)-2):
    print(S[i:i+3])
    if S[i:i+3] == "ABC":
        num += 1

print(num)
n = int(input())
s = input()
ans = 0


for i in range(n-2):
    if s[i] == 'A' and s[i+1] and s[i+2] == 'C':
        ans += 1

print(ans)
input()
string = input()

count = 0

for i in range(len(string)):
	if string[i] == 'A':
		if i < len(string)-3 and string[i+1] == 'B':
			if string[i+2] == 'C':
				count += 1


print(count)
N = int(input())
S = input()

p = 0
c = 0
for i in range(N):
    if p == 0 and S[i] == 'A':
        p = 1
    elif p == 1 and S[i] == 'B':
        p = 2
    elif p == 2 and S[i] == 'C':
        c += 1
        p = 0
    else:
        p = 0

print(c)
N = int(input())
S = input()
cnt = 0
for i in range(N-3):
  if S[i:i + 3] == 'ABC':
    cnt += 1
print(cnt)
n = int(input())
s = input()
str = "ABC"
cnt = 0
for i in range(0,n-3):
    if str == s[i]+s[i+1]+s[i+2]:
        cnt += 1
print(cnt)
N = int(input())
S = input()

ans = 0

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

while 1:
    p = S.find("ABC")
    if p == -1:
        break
    else:
        S = S[p+4:]
        ans += 1

print(ans)
N = int(input())
S = list(input())
cnt = 0

for i in range(0, N-3):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                cnt += 1
print(cnt)
# ABC150B - Count ABC
def main():
    N = int(input())
    S = input().rstrip()
    ans = sum(S[i + 3] == "ABC" for i in range(N - 3))
    print(ans)


if __name__ == "__main__":
    main()
N = int(input())
S = list(input())

ans = 0
count = 0
for i in range(len(S)):
  if count == 0:
    if S[i] == 'A':
      count = 1
  elif count == 1:
    if S[i] == 'B':
      count = 2
    else:
      count = 0
  else:
    if S[i] == 'C':
      ans += 1
    count = 0
      
print(ans)
n = int(input())
s = input()
ss = "ABC"
cnt = 0
for i in range(n-2):
  if s[i:i+3] == ss:
    print(s[i:i+3],i)
    cnt += 1
print(cnt)
n = raw_input()
s = raw_input()
print s.count(n)
n =int(input())
s =input()
k =0
for i in range(n-3):
    if s[i]=="A":
        if s[i+1]=="B" and s[i+2]=="C":
            k+=1
print(k)
n = int(input())
s = input()

c = 0
for i in range(n-3):
  if s[i:(i+3)] == 'ABC':
    c += 1

print(c)
n = int(input())
s = input()

ans = 0
for i in range(n):
    if s[i:i+2] == 'ABC':
        ans += 1

print(ans)
N=list(input())
ans=0
for i in range(len(N)-2):
  if N[i]=='A':
    if N[i+1]=='B':
      if N[i+2]=='C':
        ans=ans+1
print(N)
n = int(input())
s = input()

count = 0
for i in range(n-3):
    x = s[i:i+3]
    if x == 'ABC':
        count += 1

print(count)
import collections

n = int(raw_input())
s = map(lambda x:ord(x) - ord('a'.upper()),list(raw_input()))

count,c = 0,0
for i in s:
	if i == c:
		c +=1
	else:
		c = 0

	if c == 3:
		count +=1
		c = 0
print count
N=int(input())
S=input()

slen=len(S)
nabc=0
for i in range(0,slen-2):
  if S[i:i+2]=='ABC':
    nabc+=1

print(nabc)
N = input()
S = input()

count = 0
s = "_"
for i in range(len(S)):
    if(S[i]=="A" and s=="_"):
        s = "A"
    if(s=="A" and S[i]=="B"):
        s = "B"
    elif(s=="B" and S[i]=="C"):
        s = "_"
        count += 1
print(count)
n=int(input())
a=input()
k=0
for i in range(len(a)-3):
    if a[i]=='A':
        if a[i+1]=='B':
            if a[i+2]=='C':
                k+=1
print(k)
n=int(input())
s=list(input())
#s,t=list(input().split())
#a=list(map(int,input().split()))
#k,x=map(int,input().split())
check=["B","C"]
cnt=0
for i in range(n-3):
    if s[i]=="A":
        judge=True
        for j in range(2):
            if check[j]!=s[i+j+1]:
                judge=False
        if judge:
            cnt+=1
        else:
            pass
print(cnt)
l = int(input())
i = input()
result = 0

match = ""
for r in range(l):
  if i[r] == "A" and match == "":
    match += i[r]
  elif i[r] == "B" and match == "A":
    match += i[r]
  elif i[r] == "C" and match == "AB":
    match = ""
    result += 1
  else:
    match = ""

print(result)
n=int(input())
s=list(input())

cnt=0

for i in range(n-3):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    cnt+=1

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

print(cnt)
n=int(input())

s=input()
counter=0 
for i in range(n-2):
    if s[i]=="a" and s[i+1]=="b" and s[i+2]=="c":
        counter = counter + 1
print(counter)
N = int(input())
S = input()
c = 0
for i in range(N-2):
  if S[i:i+3]=="ABC":
    c += 0
print(c)
n = int(input())
s = list(input())
count = 0
for i in range (n-3):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        count += 1
print(count)
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 10 21:09:39 2020

@author: over-
"""

N=int(input())
S=input()

c=0

for i in range(N-3):
    if S[i:i+3]=='ABC':
        c+=1
if S=='ABC':
    c+=1        
        
print(c)
# -*- coding: utf-8 -*-
n = int(10)
s = list('ZABCDBABCQ')

result = 0
for i in range(len(s)):
    if (i > n - 3):
        break
    if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'):
        result = result + 1

print(result)