peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
s = input()

i = 0
ans = 0
while i < n-2:
	if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
		ans += 1
		i += 3
	else:
		i += 1


print(ans)
N = int(input())
S = list(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 = str(input())

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

res=0
for i in range(0, len(S)):
    if S[i:i+len(T)]==T:
        res+=1

print(res)
n = int(input())
s = list(input())
cnt=0

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

cnt = 0
for i in range(n-2):
  if "ABC" == S[i:i+3]:
    cnt += 1
print(cnt)
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 = ans + 1
    
print(ans)
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)
# -*- coding: utf-8 -*-

n = input()
s = input()
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)
def solve():
    N = int(input())
    S = input()

    if N != len(S):
        return

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

if __name__ == "__main__":
    solve()
n=int(input())
s=str(input())
ans=0
for i in range(n):
    if("ABC"==s[i:i+3]):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)
def main():
    num = int(input())
    s = input()
    cnt = 0
    for i in range(len(s) - 2):
        if s[i:i+3] == "ABC":
            cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()
n = input()
s = 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()
cnt = 0
for i in range(n-2):
    if s[i:i+3] == 'ABC':
        cnt += 1
print(cnt)
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        S = input().rstrip()

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

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()
n=int(input())
a=input()
ans=0
for i in range(n-2):
    if a[i]=="A":
        if a[i+1]=="B":
            if a[i+2]=="C":
                ans+=1
print(ans)
N = int(input())
S = input()

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

print(count)
N=int(input())
S=input()
count=0
for i in range(N):
    if (S[i:i+3]=="ABC"):
        count=count+1
print(count)
n = int(input())
s = input()
cnt = s.count('ABC')
print(cnt)
import re

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

print(len(re.findall('ABC', S)))
N = int(input())
S = input()
print(sum(1 for i in range(N) if S[i:i+3]=="ABC"))
N=int(input())
S=input()
ans=0
for i in range(len(S)):
    if S[i:i+3]=='ABC':
        ans+=1
print(ans)
N = int(input())
S = input()

count = S.count('ABC')
print(count)
N=input()
N=int(N)
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)
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    S = input()
    print(S.count('ABC'))

    
if __name__ == '__main__':
    main()
def count(s, idx):
	ac = 0
	step = 0
	bc = 0
	cc = 0
	c = 0
	while(idx < len(s) and step < 3):
		if s[idx] == 'A' and bc == 0 and cc == 0:
			ac = 1
		elif s[idx] == 'B' and cc == 0 and ac == 1:
			bc = 1
		elif s[idx] == 'C' and bc == 1 and ac == 1:
			cc = 1
		idx += 1
		step += 1
	c = ac + bc + cc
	if c == 3:
		return 1
	return 0

n = int(input())
s = input()
summ = 0
for i in range(n):
	if s[i] == 'A':
		if count(s, i) == 1:
			summ += 1
print(summ)
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
s = inputs[1].rstrip()
p, c = 0, 0
while True:
    idx = s.find('ABC')
    if idx == -1:
        break
    else:
        s = s[idx+3:]
        c += 1
print(c)
N = input()
S = input()

if (len(S) == int(N)):
    print(S.count("ABC"))
n = int(input())
s = input()
ts = s.replace('ABC','')
lts = len(ts)
print((n-lts)//3)
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    n = int(input())
    s = input()
    p = 'ABC'
    ans = 0

    for i in range(n-2):
        for j in range(3):
            if s[i+j] == p[j]:
                if j == 2:
                    ans += 1
            else:
                break
    print(ans)

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

ans = 0
for i in range(len(S)-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]=list(map(int, input().split()))
S=list(input())
c=0
for i in range (0,N-2):
    if S[i]=="A":
        if S[i+1]=="B":
            if S[i+2]=="C":
                c=c+1
print(c)
import sys

str = sys.stdin.readlines()

n = int(str[0])
str = str[1]

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


def actual(s):
    matched = re.findall('ABC', s)

    return len(matched)

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

print(actual(s))
number = int(input())
word = input()
answer = word.count('ABC')
print(answer)
n = int(input())
s = list(input().split("ABC"))
print(len(s)-1)
n,w,ans = int(input()),input(),0
for i in range(n-2):
  if w[i:i+3] == 'ABC' :
    ans += 1
print(ans)
n = int(input())
S=input()
c=0
for i in range(n-2):
    if S[i]=="A":
        if S[i+1]=="B":
            if S[i+2]=="C":
                c+=1
print(c)
input()
string = input()

count = 0

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


print(count)
n = int(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 = input()
S = S.replace("ABC", "")
print(int((N - len(S))/3))
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    S = input()
    spl = S.split("ABC")
    print(len(spl)-1)


if __name__ == "__main__":
    solve()
n = int(input())
s = str(input())
Answer = 0

for val in range(n-2):
	if s[val] != 'A' :
		continue
	elif s[val +1] != 'B' :
		continue
	elif s[val +2] != 'C' :
		continue
	else :
		Answer += 1

print(Answer)
# -*- coding: utf-8 -*-


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

count = 0

for i, s in enumerate(S[:-2]):
    if s != 'A':
        continue
    else:
        if N >= i + 2 and S[i+1] == 'B' and S[i+2] == 'C':
            count += 1

print(count)
def readinput():
    n=int(input())
    s=input()
    return n,s

def main(n,s):
    i=0
    count=0
    while(i<n):
        p=s[i:].find('ABC')
        #print(s[i:])
        if(p!=-1):
            i+=p+3
            count+=1
        else:
            break
    return count

if __name__=='__main__':
    n,s=readinput()
    ans=main(n,s)
    print(ans)
n = int(input())
s = input()

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

print(ans)
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()

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

ans = 0
for i in range(0, n - 2):
    # print(S[i: i + 3])
    if S[i: i + 3] == 'ABC':
        ans += 1
print(ans)
import sys
readline = sys.stdin.readline

N = int(readline())
S = list(map(lambda x: ord(x)-65, readline().strip()))

ans = 0
for i in range(N-2):
    for j in range(3):
        if S[i+j] != j:
            break
    else:
        ans += 1
print(ans)
N = int(input())
S = 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()
cnt=0
for i in range(n-2):
    if s[i:i+3]=="ABC":
        cnt+=1
print(cnt)
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#K, X = map(int, input().split())

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

cnt = 0
for i in range(N) :
  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=input()
n=S.count('ABC')
print(n)
n = int(input())
s = list(input())
abc_cnt = 0
cnt = 0
i = 0

while(i < n - 2):
    if(s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'):
        cnt += 1
        if i < n -3:
            i = i+3
        else:
            i += 1
    else:
        i += 1

print(cnt)
N = int(input())
S = input()
string = 'ABC'
ans = 0
for i in range(N - 2):
    if S[i:i+len(string)] == string:
        ans += 1
print(ans)
n=input()
s=raw_input().strip()
ans=0
for i in xrange(n-2):
  if s[i:i+3]=='ABC': ans+=1
print ans
s=input()
a=0
a=s.count('ABC')
print(a)
n = int(input())
S = list(input())
#print(n,S)
count = 0
count_total = 0
for a in S:
    if count == 0 and a == 'A':
        count = 'A'
    elif count == 'A' and a == 'B':
        count = 'B'
    elif count == 'B' and a == 'C':
        count = 0
        count_total += 1
    else:
        count = 0
print(count_total)
N=int(input())
S=input()
cnt=0
for i in range(N-3):
  s=S[i:i+3]
  if s=="ABC":
    cnt+=1
print(cnt)
N = int(input())
S = list(input())
ans = 0
for k in range(N-3):
  if (S[k] == 'A') and (S[k+1] == 'B') and (S[k+2] == 'C'):
    ans += 1
print(ans)
Input1 = int(input())
N = Input1
Input2 =str(input())
ar = list(Input2)



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
    else:
      chk=0
  elif chk == 2:
    if ar[i]=='C':
      chk=0
      cnt+=1
    else:
      chk=0
print(cnt)
n = int(input())
s = input()

count = 0
flag = 0
for ch in s:
  if ch=='A':
    flag = 1 if flag==0 else 0
  if ch=='B':
    flag = 2 if flag==1 else 0
  if ch=='C':
    flag = 3 if flag==2 else 0
  if flag==3:
    count += 1
    flag = 0

print(count)
from sys import stdin

lines = stdin.readlines()

n = int(lines[0].rstrip())
s = str(lines[1].rstrip())

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

import math
ans = 0

for i in range(math.ceil(len(S)/3)):
    if S[i:i+3] == "ABC":
        ans += 1
    else:
        pass
print(ans)
N = int(input())
S = input()
ct = 0
for i in range(N-3):
	if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
		ct += 1
print(ct)
N = int(input())
s = input()
cnt = 0
for i in range(N-2):
  print(s[i:i+3])
  if s[i:i+3] =="ABC":
    cnt += 1
print(cnt)
import os

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

if __name__ == '__main__':
	main()
N=input()
S=input() 
cnt=0 
y=S.find("ABC")
if y==-1:
    print(0)
else:
    while y!=-1:
        S=S.replace(S[:y],"")
        S=S.replace("ABC","",1) 
        y=S.find("ABC")
        cnt+=1 
    print(cnt)
N = int(input())
cha = input()
if "ABC" in cha:
    print(cha.count("ABC"))
n = int(input())
#a,b = map(int,input().split())
#da = list(map(int,input().split()))
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())

list=[]

for i in range(N-1):
    if S[i]=='a' and S[i+1]=='b' and S[i+2]=='c':
        list.append(i)
print(len(list))
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()
flag = 0
for i in range(n-1):
    if i == n-3:
        break
        if s[i] == 'A':
            if s[i+1] == 'B':
                if s[i+2] == 'C':
                    flag =+ 1
print(flag)
n = int(input())
s = input()

count = 0
i = 0
while i < n-3:
    if s[i:i+3] == "ABC":
        count += 1
        i += 3
    else:
        i += 1
print(count)
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A" and type == "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()
count = 0
for i in range(N-2):
  print(S[i:i+3])
  if S[i:i+3] == 'ABC':
    count += 1
print(count)
import sys; readline = sys.stdin.readline
from collections import deque

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

count = 0

for i in range(n - 2):
    if s[i:i+3] == 'abc':
        count += 1

print(count)
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
print(count)
n = int(input())
s = input()
f = "ABC"
cnt = 0
tmp = None
for s_ in s:
    if not tmp and s_ == "A":
        tmp = "A"
    elif tmp == "A" and s_ == "B":
        tmp = "B"
    elif tmp == "B" and s_ == "C":
        cnt += 1
        tmp = None
    else:
        tmp = None
print(cnt)
N = int(input())
S = str(input())

s = 0
for i in range(N-3):
    if S[i:i+3] == 'ABC':
        s = s + 1
    else:
        s = s
print(s)
n=int(input())
s = list(input())
cnt=0
for i in range(n-2):
    print(s[i:i+3])
    if s[i:i+3] ==['A', 'B', 'C']:
        
        cnt+=1
print(cnt)
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()
answer=0
for i in range(N):
    if i>=3:
        if S[i-3:i]=="ABC":
            answer+=1
print(answer)
# ABC150B - Count ABC
def main():
    N = int(input())
    S = input().rstrip()
    ans = sum(S[i:i + 3] == "ABC" for i in range(N - 3))
    print(ans)


if __name__ == "__main__":
    main()
import sys
row = sys.stdin.readline


def read_int(row):
    return int(row().rstrip())

def read_string(row):
    return row().rstrip()
  
N = read_int(row)
S = read_string(row)

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

l2 = len(s)

print(l-l2 // 3)
import sys

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

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

    print(cnt)
main()
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-2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        ans = ans + 1
a = int(input())
s = input()
cnt = 0
i = 0
while i < a:
    if s[i:i+3] == 'ABC':
        cnt += 1
        i += 3
    i += 1
print(cnt)
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
	print(sum)

if __name__ == '__main__':
	main()
n = int(input())
s = input()

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

print(count)
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=3
        count+=1
    elif j==2 and u!="C":
        j=0
print(count)
#B
N = int(input())
S = list(str(input()))

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

print(ans)
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)
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)
#!/usr/bin/env python
def main():
    S = input()    
    ans = 0
    for i in range(len(S) - 2):
        if S[i: i+3] == "ABC":
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
n=int(input())
s=input()
print(sum(s[i:i+3]=="ABC" for i in range(n-3)))
n = int(input())
s = str(input())

ans = 0
for i in range(len(s) - 3):
    if s[i:i+3] == "ABC":
        ans += 1
print(ans)
N = int(input())
S = list(input())
count = 0
for i in range(1,N-2):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count += 1
print(count)
import re

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

abc = re.compile('ABC')

count = abc.findall(s)
print(count)
n=int(input())
s=str(input())
count=0
for i in range(0, n-3):
  if s[i:i+3]=="ABC":
    count+=1
print(count)
N = int(input())
S = input()

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

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

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

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

new_S = S.replace("ABC", "@")

print(new_S)
print(new_S.count("@"))
N=int(input())
S=input()
k=0
for i in range(N-3):
    a=S[i]+S[i+1]+S[i+2]
    if a=="ABC":
        k+=1
print(k)
N=int(input())
S=input()

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

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

cnt = 0
if n == 3:
  if s == 'ABC':
    cnt +=1
else:
  for i in range(0,n-3):
    if s[i:i+3]=='ABC':
      cnt +=1
print(cnt)
N=int(input())
s=str(input())
ans=1
if 'ABC' in s:
    ans=ans+1
print(ans)
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' and count == 0:
                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 = str(input())

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

print(c)
n = int(input())
s = input()
ans = 0
for i in range(0,n-3):
  if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
    ans += 1
    
print(ans)
_ = 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
        if c != check[state]:
            state = 1
        continue
    
    state += 1
    if state == 3:
        count += 1
        state = 0

print(count)
n = int(input()) 
s = input()
print(s.count('abc'))
N = int(input())
S = input()

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

for i in range(n-2):
    print(s[i:i+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()
cnt = 0
for i in range(0, n-3):
    if s[i:i+3] == 'ABC':
        cnt += 1
print(cnt)
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

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

main()
n = int(input())
s = list(str(input()))
ans=0
for i in range(len(s) - 3):
    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-3):
    if S[i:i+3] == "ABC":
        t += 1

print(t)
input()
s = input()
i = s.find('ABC')
n = 0
while i != -1:
  i = s.find('ABC')
  s = s[i + 3:]
print(n)
n = int(input())
s = input()

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

print(count)
n = int(input())
s = str(input())
cnt = 0
for i in range(n-3):
    if s[i:i+3] == "ABC":
        cnt += 1
print(cnt)
N = int(input())
S = input()
S = S.split('C')
cut = 0
for s in S:
    s = s + 'C'
    if "ABC" in s:
        cut += 1
print(cut)
input()
s = input()
l = len(s)
s.replace('ABC', '')
 
l2 = len(s)
 
print((l-l2) // 3)
n=int(input())
s=input()
s.replace('ABC','a2c')
print(s.count('a2c'))
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()

ret = 0
cursor = 0
for s in S:
  if cursor == 0:
    if s == 'A':
      cursor = 1
  elif cursor == 1:
    if s == 'B':
      cursor = 2
    else:
      cursor = 0
  else:
    if s == 'C':
      ret += 1
      cursor = 0
    else:
      cursor = 0
      
print(ret)
N = int(input())
S = str(input())

import math
ans = 0

for i in range(math.ceil(len(S)/3)):
    print(S[i:i+3])
    if S[i:i+3] == "ABC":
        ans += 1
    else:
        pass
print(ans)
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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

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