peterverebics/CodeNet_Python_118 huggingface dataset:
N = int(input())
S = input()
c = 0
for i in range(N-2):
  if S[i] != 'A':
    continue
  else:
    if S[i+1] == 'B' and S[i+2] == 'C' and i <= N-3:
      c += 1
print(c)
str_len = int(input())
string = input()
pattern = "ABC"
res = 0
for i in range(str_len - 2):
    portion = string[i: i + 3]
    if portion == pattern:
        res += 1
print(res)
N=int(input())
S=input()
ans=0

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

print(ans)
n = int(input())
s = input()
print(len(s.split('ABC')) - 1)
N = int(input())
S = input()

import re

pattern = "ABC"

item = re.findall(pattern, S)

print(len(item))
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
  else:
    flag = 0
print(cnt)
# -*- coding: utf-8 -*-

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

start = 0
total = 0
while True:
    number = S.find('ABC', start)
    if number == -1:
        break

    start = number + 3
    total += 1

print(total)
num=int(input())
moji=input()
print(moji.count("ABC"))
n=int(input())
s=input()
ans=0
a=0
for i in range(n-2):
  if s[i]=="A":
    if s[i+1]=="B":
      if s[i+2]=="C":
        ans=ans+1
print(ans)
def main():
    N = int(input())
    S = input()

    print(S.count("ABC"))


if __name__ == "__main__":
    main()
n=int(input())
s=input()
ans=0
for i in range(n-2):
  if s[i:i+3] == "ABC":
    ans+=1
print(ans)
N = int(input())
S = input()
ans = 0
while 'ABC' in S:
    ans += 1
    ind = S.find('ABC')
    S = S[ind+3:]
print(ans)
N=int(input())
S=list(input())
i=0
c=0
while i<N-2:
  if S[i]=='A':
    if S[i+1]=='B':
      if S[i+2]=='C':
        c+=1
        i+=1
      else:
        c+=0
        i+=1
    else:
      c+=0
      i+=1
  else:
    c+=0
    i+=1
else:
  print(c)
N = int(input())
S = input()

ans = 0

for i in range(0, N):
    if len(S[i:i+3]) < 3:
        break

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

print(ans)
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    S=input()

    ans=0
    for i in range(n-2):
        ans+=S[i:i+3]=="ABC"

    print(ans)
resolve()
N = int(input())
S = str(input())
cou = 0
for i in range(N-2):
  if S[i:i+3] == "ABC":
    cou += 1
print(cou)
N=int(input())
S=str(input())
print(S.count('ABC'))
n = int(input())
s = input()
count = 0
for i in range(n-2):
    if s[i:i+3] == 'ABC':
        count += 1
print(count)
n = int(input())
s = input()

ans = 0

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

count=0
for i in range(N-2):
    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-2):
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                ans += 1
print(ans)
N = int(input())
S = input()

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

print(count)
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    input()
    s=input()
    print(s.count("ABC"))
main()
import sys

def input():
    return sys.stdin.readline()[:-1]

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

cnt = 0
for i in range(N-2):
    k = S[i:i+3]
    if k=='ABC':
        cnt += 1
print(cnt)
N=int(input())
S=input()
icnt=0
for i in range(N-2):
    if S[i]=="A" :
        if S[i+1]=="B" :
            if S[i+2]=="C":
                icnt=icnt+1
print(icnt)
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
    elif S[i] == 'A':
      count = 1
    else:
      count = 0
  else:
    if S[i] == 'C':
      ans += 1
      count = 0
    elif S[i] == 'A':
      count = 1      
    else:
      count = 0
      
print(ans)
n=int(input())
s=input()

ans = s.count('ABC')
print(ans)
n = int(input())
s = input()
ans = 0
for i in range(n-2):
    if s[i:i+3] == 'ABC':
        ans += 1
print(ans)
n1 = int(input())
s2 = input()

c3 = s2.count("ABC")

print(c3)
N = int(input())
s = input()

ans = 0

for i in range(0,N-2):
	if s[i:i+3] == "ABC":
		ans += 1

print(ans)
N = int(input())
S = str(input())
print(S.count("ABC"))
N = int(input())
S = list(input())

res = 0
for i in range(len(S)-2):
    if ''.join(S[i:i+3])== 'ABC':
        res += 1

print(res)
N=int(input())
S=input()
temp=""
ans=0
for i in range(N):
	if S[i]=="A":
		temp="A"
	elif S[i]=="B" and temp=="A":
		temp="B"	
	elif S[i]=="C" and temp=="B":
		temp=""
		ans+=1
	else:
		temp=""

print(ans)
n=int(input())
s=input()
g=0
for c in range(n-2):
    if s[c:c+3]=="ABC":
        g+=1
print(g)
n = int(input())
s = input().replace('ABC','1')
print(s.count('1'))
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()
	
	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()
input()
a=input()
b=0
for i in range(len(a)-2):
  b+=a[i]+a[i+1]+a[i+2]=='ABC'
print(b)
n = int(input())
s = list(str(input()))
ans=0
for i in range(len(s) - 2):
    if s[i] == 'A':
        if s[i + 1] == 'B':
            if s[i + 2] == 'C':
                ans+=1
print(ans)
N = int(input())
S = input()
counter = 0
for i in range(N):
    if S[i:i+3] == 'ABC':
        counter += 1
print(counter)
N=int(input())
S=input()

ans=0
for i in range(N-2):
    if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C':
        ans += 1
print(ans)
import sys
import itertools

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

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

print(count)
n = int(input())
s = input()
ans = 0
for i in range(n-2):
    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 = str(input())

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



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

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

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

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    S = INPUT()

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

    print(cnt)


if __name__ == '__main__':
    main()
_ = input()
s = input()

cnt = 0
for i in range(len(s)-2):
    if s[i:i+3] == "ABC":
        cnt += 1
print(cnt)
n=int(input())
s=str(input())
#s=list(s)
count=0
i=0
ans=s.count("ABC")
  
print(ans)
N = int(input())
S = input()
s = []
b=0
for i in S:
    s.append(i)
for i in range(N-2):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        b+=1
print(b)
n = int(input())
s = list(input())
count = 0
for i in range(0,n-2):
    if s[i] + s[i+1] + s[i+2] == "ABC":
        count+=1
print(count)
n = int(input())
s=input()
ans=0
for i in range(n-2):
    if "ABC"==s[i:i+3]:
        ans+=1
print(ans)
from sys import stdin
n = int(input())
s = stdin.readline().rstrip()

j = 0
for i in range(n-1):
  if s[i-1:i+2] == "ABC":
    j=j+1

print(j)
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())

target = "ABC"

val = S.count(target)
print(val)
n = int(input())
s = input()

index_no = [i for i,x in enumerate(s) if x == "A"]

ans = 0
for j in index_no:
    if "ABC" == s[j:j+3]:
        ans += 1

print(ans)
N = int(input())
S = input()
count = 0
for i in range(0,N-2):
  if S[i:i+3] == "ABC":
    count += 1
print(count)
N = int(input())
S = input()
ans = 0
if N > 3:
  for i in range(N-2):
    if S[i:i+3] == "ABC":
      ans += 1
else:
  ans = 1 if S == "ABC" else 0
print(ans)
n = int(input())
s = input().strip()

cnt = 0

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

print(cnt)
N = int(input())
S = input()
count = S.count("ABC")
print(count)
n = int(input())
s = input()
target = 'ABC'

res = 0
start=0
while True:
    next = s.find(target,start)
    if next == -1:
        break
    res += 1
    start = next + 3

print(res)
def main():
    n = int(input())
    s = list(input())

    ans = 0
    for i in range(n-2):
        abc = str(s[i]) + str(s[i+1]) + str(s[i+2])
        if abc == "ABC":
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
N=int(input())
S=input()
a=0
for i in range(N-2):
    if S[i:i+3]=="ABC":
        a+=1
print(a)
N = int(input())
S = str(input())

cnt = 0

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

ans = S.count('ABC')

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

c = 0
for i in range(0,len(S)-1):
  if S[i:i+3]==["A","B","C"]:
    c += 1

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

s = s.replace("ABC","")

print((n-len(s))//3)
def main():
    # 入力
    n = int(input())
    s = input()

    print(s.count("ABC"))


main()
N = int(input())
S = str(input())

def main():
    print(S.count('ABC'))

if __name__ == "__main__":
    main()
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

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


if __name__ == '__main__':
    main()
N = int(input())
S = input()
count = 0
for i in range(N):
    if S[i:i+3]=='ABC':
        count += 1
print(count)
import math
from collections import deque
def main():
    n = int(input())
    s = input()

    print(s.count("ABC"))

if __name__ == "__main__":
    main()
n = input()
s = input()
t = s.replace('ABC','')
print(int((len(s)-len(t))/3))
N = int(input())
S = input()
count = 0

for i in range(N-2):
    if S[i]=='A' and S[i+1] == 'B' and S[i+2] == 'C':
        count = count + 1

print(count)
n = int(input())
s = input()
c = 0
for i in range(n-2):
  if s[i:i+3] == 'ABC':
    c += 1
print(c)
N = int(input())
S = input()
# S='ABCDE'

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

print(ans)
N = int(input())
S = input()
ans = S.count('ABC')
print(ans)
def solve():
    N = int(input())
    S = input()
    count = 0

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

    print(count)


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

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

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

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

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

count = 0

while True:
    index_ABC = S.find('ABC')
    if index_ABC != -1:
        S = S[:index_ABC] + S[index_ABC + 3:]
        count += 1
    else:
        break

print(count)
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    for j in range(i+1, n+1):
        if s[i:j] == 'ABC':
            ans += 1
print(ans)
N = input()
s = list(input())

ans = 0
for i in range(len(s)-2):
  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-2):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    c+=1
print(c)
n = int(input())
s = str(input())
count = 0
for i in range(n-2):
    if s[i:i+3] == "ABC":
        count += 1
    else:
        pass
print(count)
K=int(input())
l=list(input())
c=0
for i in range(K-2):
    if l[i]=="A":
        if l[i+1]=="B":
            if l[i+2]=="C":
                c+=1
print(c)
N=int(input())
S = input()
s = 0
for i in range(0,N-2):
    if S[i:i+3] == "ABC":
        s += 1
print(s)
N = int(input())
S = input()

ans = 0

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

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

print(t)
n=int(input())
s=input()
cnt=0
for i in range(n-2):
    if s[i]=='A':
        if s[i+1]=='B' and s[i+2]=='C':
            cnt+=1
print(cnt)
N = int(input())
S = input()
c = 0

for i in range(N-2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        c = c + 1
print(c)
# coding: utf-8

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

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

count = 0

for i in range(N-2):
	if S[i] == 'A':
		if S[i+1] == 'B' and S[i+2] == 'C':
			count += 1

print(count)
n=int(input())
s=input()
import re

m = re.findall("ABC", s)
print(len(m))
n = int(input())
l = input()
cnt =  0
for i in range(n-2):
    if l[i:i+3] == 'ABC':
        cnt += 1
print(cnt)
N=int(input())
S=list(input())

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

for i in range(len(s)-2):
  if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
    count += 1
    
print(count)
n = int(input())
s = input()
count = 0
for i in range(n-2):
    if s[i]!="A":
        pass
    else:
        if s[i+1]!="B":
            pass
        else:
            if s[i+2]!="C":
                pass
            else:
                count += 1
    
print(count)
n = int(input())
X = input()
a = 0
for i in range(n-2):
  if X[i] + X[i+1] + X[i+2] == 'ABC':
    a +=1
  else:
    a +=0
      
print(a)
N = int(input())
S = input()
count = 0
for i in range (N-2):
	if S[i] == "A":
		if S[i+1] == "B":
			if S[i+2] == "C":
				count += 1
				
print(count)
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A":
        type = "B"
    elif char == "B" and type == "B":
        type = "C"
    elif char == "C" and type == "C":
        count += 1
        type = "A"
    else:
        type = "A"
print(count)
N = int(input())
S = input()

counts=0

for i in range(len(S)-2):
	if (S[i:i+3]) == 'ABC':
		counts+=1
    
print(counts)
n=int(input())
s=input()
cnt=0
for i in range(len(s)-2):
  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-2):
	if s[i:i+3] == "ABC":
		cnt += 1

print(cnt)
n=int(input())
s=input()
print(sum(s[i:i+3]=="ABC" for i in range(n-2)))
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

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

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

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


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    print(str(readline().rstrip().decode('utf-8')).count("ABC"))


if __name__ == '__main__':
    solve()
n = int(input())
s = input()
t = s.count("ABC")
print(t)
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
s = input()
print(s.count('ABC'))
N = int(input())
S = list(input())


cn = 0

for i in range(N-2):
    if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
        cn = cn + 1
        
        
print(cn)
n = int(input())
s = str(input().upper())
print(s.count("ABC"))
N=int(input())
S=input()
c=0
for i in range(N-2):
  if S[i:i+3]=="ABC":
    c+=1
print(c)
N = int(input())
S = input()

ans = 0

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

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

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

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

    print(S.count('ABC'))

if __name__ == '__main__':
    main()
n=int(input())
x=input()
y=x.count("ABC")
print(y)
n = int(input())
s = input()

sr = s.replace("ABC", "")

ans = (n - len(sr)) // 3

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

if len(S) != N:
    exit()

S = S.upper()

c = S.count('ABC')

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

ans = s.count("ABC")
print(ans)
N = int(input())
S = input()

print(len([0 for c1, c2, c3 in zip(S, S[1:], S[2:]) if c1 == 'A' and c2 == 'B' and c3 == 'C']))
N = int(input())

S = input().strip()

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

print(count)
import re

_ = input()
x = input()

print(len(re.findall(r"ABC", x)))
N = int(input())
S = input()
'''Solution 1'''
# print(S.count('ABC'))
'''Solution 2'''
count = 0
for i in range(N):
    if S[i:i+3] == 'ABC':
        count+=1
print(count)
N = int(input())
S = input()
cnt = 0
for i in range(N-2):
    if S[i:i+3] == 'ABC':
        cnt += 1
print(cnt)
N = int(input())

S = input()
index = -1
if "ABC" in S:
  S = S.split("ABC")
  print(len(S)-1)
  
  
else:
  print("0")
N = int(input())
S = input()

ans = 0
for i in range(N-2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        ans += 1
        
print(ans)
A = int(input())
B = input()
result = 0
for i in range(A):
    if B[i] == "A" and B[i:i+3] == "ABC":
        result += 1
print(result)
n = int(input())
s = input()
c = 0
for i in range(len(s) - 2):
    if s[i:i + 3] == 'ABC':
        c += 1
print(c)
n = int(input())
s = input()
flag = 0
for i in range(n-1):
    if i == n-2:
        break
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                flag += 1
print(flag)
n=int(input())
s=input()
result=s.count('ABC')
print(result)
n=int(input())
s=input()
print(sum(s[i:i+3]=='ABC' for i in range(n-2)))
n = int(input())
s = input()

ans = 0

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

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

ans = 0

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

print(ans)
N=int(input())
S=input()
count=0
for i in range(N):
  if S[i]=='A':
    if S[i+1:i+3]=='BC':
      count+=1
print(count)
n = int(input())
s = input()
ans = s.count('ABC')
print(ans)
def main():
    N = int(input())
    S = input()
    print(S.count('ABC'))

main()
N = int(input())
S = input()
count = 0

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

n = int(input())
s = input()

print(s.count(abc))
N = map(int,input())
S = input()

ans = S.count('ABC') 

print(ans)
n = int(input())
s = input()
cnt = 0
for i in range(n-2):
    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-2):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        cnt+=1
print(cnt)
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+1):
        if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
            count+=1
print(count)
import re

n = int(input())
s = input()
print(len(re.findall('ABC', s)))
N = int(input())
a = list(input())
count=0
for i in range(N):
  if a[i] == 'A' and i<len(a)-2:
    if a[i+1]=='B' :
      if a[i+2]=='C':
        count+=1
        
print(count)
N = int(input())

S = input()

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

print(count)
from sys import stdin
import math

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

print(s.count('ABC'))
n = int(input())
s = input()

ans = 0

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

print(ans)
if __name__ == "__main__":
    n = int(input())
    s = input()

    ans = 0

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

    print(ans)
n=int(input())
s=input()
ans=0
for i in range(n-2):
  if s[i:i+3]=="ABC":
    ans+=1
print(ans)
#!/usr/bin/env python3
import sys


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

    print(result)

    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=list(input())
ans=0
for i in range(N-2):
    if S[i]=="A" and S[i+1]=="B" and S[i+2] =="C":
        ans+=1

print(ans)
# coding: utf-8
n = int(input())
S = input()

count = 0

for i in range(n):
    if S[i:i+3] == 'ABC':
        count += 1
print(count)
n = int(input())
s = input()

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

ABCsp = S.split('ABC')
ABCsp = ''.join(ABCsp)
print(int(len(S)-len(ABCsp)) // 3)
n = int(input())
s = str(input())

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

def res():
    ct=0
    for i in range(n):
        if i+2 > n-1:
            return ct
        if s[i] =="A"and s[i+1]=="B" and s[i+2]=="C":
            ct+=1

print(res())
# -*- 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-2):
    if S[i:i+3]=='ABC':
        c+=1
      
print(c)
n = int(input())
m = str(input())
a = m.count('ABC')
print(a)
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = s()
print(s.count("ABC"))
L = int(input())
S = input()

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

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

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

print(ans)