peterverebics/CodeNet_Python_118 huggingface dataset:
n, m = map(int, input().split())
ac = []
sb = []
for i in range(m):
    p, s = input().split()
    p = int(p)
    sb.append([p, s])
    if s == "AC":
        ac.append(p)
a = 0
w = 0
for q, st in sb:
    if q in ac:
        if st == "AC":
            a += 1
            ac.remove(q)
        else:
            w += 1
print(str(a) + " " + str(w))
n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]
ac = 0
wa = 0
for i in range(1, n+1):
    for j in range(m):
        if int(ps[j][0]) == i: 
            if ps[j][1] == "AC":
                ac += 1
                break
            elif ps[j][1] == "WA":
                wa += 1
print(ac, wa)
from collections import defaultdict

n, m = map(int, input().split())

d = defaultdict(int)
res_ans = 0
res_pena = 0

for _ in range(m):
    p, s = input().split()
    if s == "AC":
        if d[p] == -1:
            continue
        else:
            res_ans += 1
            res_pena += d[p]
            d[p] = -1
    else:
        d[p] += 1

print(res_ans, res_pena)
class Question:
    def __init__(self, num, result):
        self.num = int(num)
        self.result = result


n, m = map(int, input().split())
p_list = [input().split() for _ in range(m)]
questions = [Question(num, result) for num, result in p_list]

collect_list = []
wa_count = 0

for q in questions:
    if not(q.num in collect_list):
        if q.result == 'AC':
            collect_list.append(q.num)
        else:
            wa_count += 1
print('{} {}'.format(len(collect_list), wa_count))
n,m=map(int,input().split())
dict={}
r1,r2=0,0
for _ in range(m):
  p,s=input().split()
  if not p in dict:
    dict[p] = ['WA']
  if s == 'WA' and dict[p][-1]=='WA':
    dict[p].append('WA')
  elif s == 'AC' and dict[p][-1] == 'WA':
    dict[p].append('AC')
r1 = len(dict)
for i in dict.values():
  r2 += len(i)-2
print(r1,r2)
def resolve():
    n, m = map(int, input().split())
    co = 0
    pe = 0
    bl = False
    ps = "0"
    for _ in range(m):
        p, s = map(str, input().split())
        if ps != p:
            bl = False
        if s == "AC" and p!=ps:
            co += 1
            bl = True
            ps = p
        elif bl is False and s == "WA":
            pe += 1
    print(co, pe)
resolve()
n, m = map(int, input().split())
pss = [list(input().split()) for _ in range(m)]
ac = [0] * n
ans1 = 0
ans2 = 0
for i in range(m):
    if ac[int(pss[i][0]) - 1] == 0:
        if pss[i][1] == 'AC':
            ans1 += 1
            ac[int(pss[i][0]) - 1] = 1
        else:
            ans2 += 1
    else:
        continue
print(str(ans1) + ' ' + str(ans2))
n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    pp, ss = input().split()
    p.append(int(pp) - 1)
    s.append(ss)

acs = [0] * n
was = [0] * n
for i in range(m):
    if s[i] == 'AC':
        acs[p[i]] = 1
    else:
        if acs[p[i]] == 0:
            was[p[i]] += 1
print("{} {}".format(sum(acs), sum(was)))
N, M = map(int, input().split())
isAC = [0]*N
ac = 0
wa = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not isAC[p-1]:
        if s == 'AC':
            isAC[p-1] = 1
            ac += 1
        else:
            wa += 1
            
print(ac, wa)
n, m = map(int, input().split())
flg = [0]*n
ac = 0
pe = 0

for i in range(m):
    p, s = input().split()
    if flg[int(p)-1] == 0:
        if s == "WA":
            pe += 1
        else:
            flg[int(p)-1] = 1
            ac += 1
print(ac, pe)
n,m = map(int, input().split())

solved = []
correct = 0
penalty = 0

for i in range(m):
    p,s = input().split()
    p = int(p)

    if p not in solved:
        if s == "WA":
            penalty += 1
        elif s == "AC":
            correct += 1
            solved.append(p)

print(correct, penalty)
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])
 
quiz_dict = {}
wa_dict = {}
 
for i in range(M):
  tmp = input().split()
  
  quiz = tmp[0]
  res = tmp[1]
  
  quiz_dict[quiz] = 0
  
  if quiz not in wa_dict: 
    wa_dict[quiz] = 0
  
  if res == "AC":
    quiz_dict[quiz] = 1
  if res == "WA":
    wa_dict[quiz] += 1
wa_n = sum(wa_dict.values()) 

def filter_dict(f, d):
  return {k:v for k,v in d.items() if f(k,v)}

a = len(filter_dict(lambda k,v: v==1, quiz_dict))

print(a, wa_n)
n,m = map(int,input().split())
ac, wa=[], {}
for i in range(m):
  p,s = map(str, input().split())
  if s=='AC': ac.append(p)
  elif (s=='WA') and (p not in ac):
    if p not in wa.keys(): wa[p]=1
    else: wa[p]+=1
penalty = sum(wa.values())
clear = len(set(ac))
print('%d %d'%(clear,penalty))
n,m = (int(x) for x in input().split())
p = [0]*m
s = [0]*m
penal = [0]*n
clear = [0]*n
for i in range(m):
    p[i],s[i] = (x for x in input().split())
    p[i] = int(p[i])
    if s[i] == 'AC':
        clear[p[i]-1]=1
    elif clear[p[i]-1] == 0:
        penal[p[i]-1] += 1
print(str(sum(clear)) + " " + str(sum(penal)))
N,M=map(int,input().split())
AC=[0]*N
pts=0
pena=0
for i in range(M):
    a,b=map(str,input().split())
    if b=='AC':
        if AC[int(a)-1]==0:
            AC[int(a)-1]=1
            pts+=1
    else:
        if AC[int(a)-1]==0:
            pena+=1
print(pts,pena)
N,M = map(int,input().split())
q = ["" for i in range(N)]
wa = 0
ac = 0
for i in range(M):
    p,s = map(str,input().split())
    if s == "WA" and (q[int(p)-1] == "" or q[int(p)-1] == "WA"):
        q[int(p)-1] = "WA"
        wa+=1
    elif s == "AC" and (q[int(p)-1] == "" or q[int(p)-1] == "WA"):
        q[int(p)-1] = "AC"
        ac+=1
print(ac,wa)
import sys

class problem():
  def __init__(self, n, s):
    self.num = n
    self.result = s


n, m = map(int, input().split())
ckn = []
flag = 0
fac = 0
swa = 0
ac = 0

for i in sys.stdin:
  pm, c = i.split()
  if not(int(pm) in ckn):
    if c == 'WA':
      swa += 1
      if flag == 0:
        fac += 1
    elif c == 'AC':
      ckn.append(int(pm))
      ac += 1
      if flag == 0:
        flag += 1

if ac == 0:
  fac = -1
  
print(fac + 1, swa)
n,m = map(int, input().split())
penalty = [[0,0] for i in range(n)]

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s=='AC':
        penalty[p][0]=1
    else:
        if penalty[p][0]==0:
            penalty[p][1]+=1
a = 0
b = 0
for i in range(n):
    a += penalty[i][0]
    b += penalty[i][1]
print(a,b)
N, M = map(int, input().split())
right = set()
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        right.add(p)
    if S == 'WA':
        if p not in right:
            penalty += 1
print(len(right), penalty)
n,m=map(int,input().split())
a=[[0,0] for _ in range(n)]
for i in range(m):
  dk,*d=list(map(str,input().split()))
  if d==['AC']:
    a[int(dk)-1][0]=1
  else:
    if a[int(dk)-1][0]==0:
      a[int(dk)-1][1]+=1
ntp=list(zip(*a))
ans=str(sum(ntp[0]))+' '+str(sum(ntp[1]))
print(ans)
N, M = [int(x) for x in input().split()]

obj = {}
ii = 0
jj = 0

for i in range(M):
    p = [x for x in input().split()]
    key = p[0]
    res = p[1]
    if key not in obj:
        obj[key] = {'AC': 0, 'WA': 0}
    if res == 'WA' and obj[key]['AC'] > 0:
        obj[key]['WA'] = obj[key]['WA'] + 1
    if res == 'AC':
        obj[key]['AC'] = 1

for k in obj:
    ii = ii + obj[k]['AC']
    jj = jj + obj[k]['WA']


print(ii, jj)
#c = input()
#n = int(input())
n, m = map(int, input().split())

b = [[0] for i in range(n)]

acnt = 0
wcnt = 0

for i in range(m):
    p, s = map(str, input().split())
    if s == "WA":
        if b[int(p)-1][0] == 0:
            wcnt += 1
    else:
        if b[int(p)-1][0] == 0:
            acnt += 1
            b[int(p)-1][0] = 1
    

print(acnt, wcnt)
import collections
k,n = map(int, raw_input().split(' '))


cc = {'AC': collections.Counter(), 'WA': collections.Counter()}
for _ in range(n):
	i,res = raw_input().split(' ')
	i = int(i)
	if res == 'AC':
		cc['AC'][i] += 1
	elif res == 'WA':
		cc['WA'][i] += 1
s = 0
for p in cc['AC']:
	s += cc['WA'][p]
print len(cc['AC']), s #len(penalties)
N,M = map(int,input().split())
k = []
ac_count = 0
miss_count = 0
for i in range(M):
    s = input().split()
    if s[1] == "AC":
        if s[0] not in k:
            k.append(s[0])
            ac_count += 1
    else:
        if s[0] not in k:
            miss_count += 1
print(ac_count,miss_count)
"""
flag がTrueのときAC済み。falseのときWAのみ
flag == Falseかつ


"""

n, m = map(int, input().split())
ps = []
for i in range(m):
    p, s = input().split()
    ps.append([int(p), s])
flag = [False for _ in range(n)]
ac = 0
wa = 0
i = 0

while i < m :
    p = ps[i][0]
    s = ps[i][1]
    if s == "WA" and flag[p - 1] == False:
        wa += 1
    elif s == "AC" and flag[p - 1] == False:
        ac += 1
        flag[p - 1] = True
    i += 1

print(str(ac) + " " + str(wa))
n,m = map(int,input().split())
L = [0]*n
ans = 0
penalty = 0
for i in range(m):
  p,q = input().split()
  if q == 'AC':
    if L[int(p)-1] == 0:
      L[int(p)-1] = 1
    ans += 1
  else:
    if L[int(p)-1] == 0:
      penalty += 1
print(ans,penalty)
# coding: utf-8
import re
import math
#import numpy as np


#main
n,m=map(int,input().split())
MAP={}
PS=[]
for a in range(m):
    s,t=input().split()
    if(not s in MAP):MAP[s]=[]
    MAP[s].append(t)
ac=0
wa=0
for a,b in MAP.items():
    if(not "AC" in MAP[a]):continue
    for c in b:
        if(c=="WA"):
            ac+=1
        else:
            wa+=1
            break
print(ac,wa)
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
    else:
      	tmp = ""
  elif "C" == elem and tmp != "":
    if tmp[-1] == "B":
    	cnt += 1
    tmp = ""
  else:
    tmp = ""
print(cnt)
_=input()
s=input().split("ABC")
print(len(s)-1)
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(N-2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        count += 1

print(count)
import numpy as np

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)
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = sr()
answer = S.count('ABC')
print(answer)
import re

n = int(input())
text = input()

pattern = "ABC"
result = re.findall(pattern, text)
print(len(result))
# coding: utf-8
# Your code here!

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

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

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

cnt = 0

for i in range(len(s)):
    if s[i] == "A" and i+2 <= len(s)-1:
        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-2):
    if s[i:i+3] == "ABC":
        ans += 1

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

print(sum(s[i:i+3]=='ABC' for i in range(n-2)))
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 = str(input())

print(S.count('ABC'))
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()
cnt = 0
num = 0

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

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

print(len(re.findall('ABC', s)))
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
    elif s == 'A':
      cursor = 1
    else:
      cursor = 0
  else:
    if s == 'C':
      ret += 1
      cursor = 0
    elif s == 'A':
      cursor = 1
    else:
      cursor = 0
      
print(ret)
import math

n = int(input())

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

print(count)
_ = int(input())
s = str(input())

ans = 0
for i in range(len(s)-2):
    ans += "ABC" == '{}'.format(s[i:i+3])

print(ans)
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)
a = input()
b = input()
ABC = 0
for i in range(int(a)-2):
  if b[i:i+3] == "ABC":
    ABC +=1
print(ABC)
N = int(input())
S = input()
 
print(S.count('ABC'))
N = int(input())
S = input()

abc = ""
result = 0

for x in S:
    abc += x
    if x == 'C':
        if abc[-3:] == "ABC":
            result += 1

print(result)
N = int(input())
S = input()
cnt = 0
for i in range(N-2) :
    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 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()

target = 'ABC'

print(S.count(target))
input()
s = input()
n = 0
i = 0
while i != -1:
  i = s.find('ABC')
  s = s[i+3:]
  n += 1
print(n-1)
n = int(input())
s = input()
ans = 0
for i in range(n):
    if s[i:i+3] == "ABC":
        ans += 1
print(ans)
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
print(cnt)
N = int(input())
S = input()

def main():
    print(S.count("ABC"))
    return

if __name__ == "__main__":
    main()
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()
cnt=0
while 'ABC' in s:
	s=s.replace('ABC','',1)
	cnt+=1
print(cnt)
n=int(input())
s=str(input())
ans=s.count('ABC')
print(ans)
# -*- coding:utf-8 -*-
n = int(input())
s = input()

print(s.count('ABC'))
n = int(input())
s = input()
sum = 0
for i in range(n-2):
  if (s[i]=='A'):
    if(s[i+1]=='B'):
      if(s[i+2]=='C'):
        sum = sum + 1
print(sum)
import sys
import math
import bisect


def main():
    n = int(input())
    s = input()
    ans = 0
    for i in range(n):
        if i + 3 <= n:
            if s[i:i+3] == 'ABC':
                ans += 1
    print(ans)

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

print(sum([1 for i in range(n-2) if s[i:i+3] == 'ABC']))
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-3+1):
#	print(s[i],s[i+1],s[i+2])
	if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
		count = count + 1
print(count)
def solve():
    n = int(input())
    s = input()
    tmp = 0
    for i in range(n - 2):
        if (s[i], s[i+1], s[i+2]) == ("A", "B", "C"):
            tmp += 1
    print(tmp)
solve()
N = int(input())
S = input()
print(sum([1 for i in range(N-2) if S[i]+S[i+1]+S[i+2] == "ABC"]))
n = int(input())
s = str(input())

if "ABC" in s:
    print(s.count("ABC"))
else:
    print(0)
N=int(input())
S=list(input())
a=0
for i in range(0,N-2):
    if (S[i]+S[i+1]+S[i+2])=='ABC':
        a+=1
print(a)
n=int(input())
s=str(input())
print(s.count("ABC"))
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:
        if not(stackString == "a" and s == "A"):
            stackString = ""
print(resultCount)
# coding: utf-8
N = int(input())
S = input()
cnt = 0

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

print(cnt)
n=int(input())
s=input()
l=[]
for i in s:
    l.append(i)
#print(l)
count=0
for i in range(len(l)-2):
    if l[i]=="A" and l[i+1]=="B" and l[i+2]=="C":
            count+=1
print(count)
N=int(input())
S=input()
ans=0
for i in range(N):
    if S[i]=='A':
        if i+1<N and S[i+1]=='B':
            if i+2<N and S[i+2]=='C':
                ans+=1
print(ans)
n = int(input())
s = list(input())
a = []
count = 0

for i in range(0,n-2):
    a = s[i:i+3]
    if a == ["A","B","C"]:
        count += 1

print(count)
class Solution:
    def CountABC(self, s: str):
        if len(s) < 3:
            return 0
        count = 0
        for idx in range(len(s)):
            if s[idx : idx + 3] == "ABC":
                count += 1
        return count


if __name__ == "__main__":
    n, s = int(input()), input()
    solution = Solution()
    print(solution.CountABC(s))
N = int(input())
S = list(input())
flag=1
count=0

txt = ['A','B','C']
for i in range(N-2):
    for j in range(3):
        if S[i+j]!=txt[j]:
           flag=0
           break
    if flag==1:
        count+=1
    flag=1
print(count)
n=int(input())
s=input()
count=s.count('ABC')
print(count)
import re

# N, Sを入力
n = input()
s = input()

results = re.findall(r"ABC", s)

print(len(results))
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 = input()
ans = 0

for i in range(len(S)-2):
    tmp = 0
    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)
# B - Count ABC

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
print(cnt)
def main():
    _ = int(input())
    s = input()
    keyword = "ABC"
    count = 0
    while keyword in s:
        s = s.replace(keyword, "", 1)
        count += 1

    print(count)


if __name__ == "__main__":
    main()
import sys
input = lambda: sys.stdin.readline().rstrip()

def 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)

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

S=list(S)

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

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


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

nums = s.count('ABC')

print(nums)
n=int(input())
s=input()
t="ABC"

print(s.count(t))
# 140 B

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

for i in range(len(s)):
    if s[i] == 'A':
        try:
            if s[i + 1] == 'B' and s[i + 2] == 'C':
                num += 1
        except:
            pass

print(num)
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

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

    print(ans)
    return


if __name__ == '__main__':
    main()
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

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)
if __name__ == '__main__':

	input()
	S = input()

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

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

repeater = re.compile('ABC')
result = repeater.findall(s)
print(len(result))
# 初期入力
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)
"""
a=S.count("ABC")

print(a)
def 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)
if __name__ == '__main__':
    main()
#ABC150B
n = int(input())
s = input()
print(s.count("ABC"))
N = int(input())
S = list(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()
thre = "ABC"
res = 0
for i in range(N-2):
  if thre == S[i:i+3]:
    res +=1
print(res)
N = int(input())
S = input().split("ABC")
print(len(S)-1)
n = int(input())
s = input()
abc = "ABC"
cnt = 0
for i in range(len(s)-2):
    for j in range(3):
        if s[i+j] != abc[j]:
            break
    else:
        cnt += 1
print(cnt)
N = int(input())
S = list(input())
cnt =0
for i in range(N-2):
  if S[i] =="A":
    if S[i+1] =="B":
      if S[i+2] == "C":
        cnt +=1
print(cnt)
N = int(input())
S = input()

Slist = list(S)

count = 0

Slist.append('0')
Slist.append('0')

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


print(count)

#print('N = ', N)
#print('S = ', S)
#print('Slist = ', Slist)
n = int(input())
s = list(input())
ans = 0

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

print(ans)
n=int(input())
s=input()
flag=0
ans=0
for si in s:
    if si=='A':
        flag=1
    elif si=='B' and flag==1:
        flag=2
    elif si=='C' and flag==2:
        ans+=1
        flag=0
    else:
        flag=0
print(ans)