Problem:
 Score : 200 points    Problem Statement We have a string S of length N consisting of uppercase English letters.  How many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?      Constraints  3 \leq N \leq 50  S consists of uppercase English letters.         Input Input is given from Standard Input in the following format:  N  S       Output Print number of occurrences of ABC in S as contiguous subsequences.        Sample Input 1 10
ZABCDBABCQ      Sample Output 1 2  Two contiguous subsequences of S are equal to ABC : the 2 -nd through 4 -th characters, and the 7 -th through 9 -th characters.       Sample Input 2 19
THREEONEFOURONEFIVE      Sample Output 2 0  No contiguous subsequences of S are equal to ABC .       Sample Input 3 33
ABCCABCBABCCABACBCBBABCBCBCBCABCB      Sample Output 3 5

Solution (Python):
a=int(input())
b=input()
sum=0
for i in range(a-2):
	if b[i:i+1] == "A":
		if b[i+1:i+2] == "B":
			if b[i+2:i+3] == "C":
				sum+=1
			pass
		pass
	pass
print(sum)

Solution (Python):
n=int(input())
s=str(input())
s=s.replace('ABC','')
l=len(s)
x=int((n-l)/3)
print(x)

Solution (Python):
n = int(input())
i =input()

c=0

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

Solution (Python):
N = int(input())
S = input()

count = 0

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

print(count)

Solution (Python):
N = input()
S = input()

print(S.count("ABC"))

Solution (Python):
x = int(input())
str = input()
print(str.count('ABC'))

Solution (Python):
N = int(input())
S = input()
print(S.count("ABC"))

Solution (Python):
X = int(input())
S = input()
print(S.count('ABC'))

Solution (Python):
n = input()
s = input()
print(s.count('ABC') )

Solution (Python):
def main():
    n = int(input())
    s = input()
    print(s.count('ABC'))

main()

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

Solution (Python):
N = int(input())
S = input()

print(S.count("ABC"))

Solution (Python):
N = int(input())
S = input()
str = "ABC"
print(S.count(str))

Solution (Python):
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)

Solution (Python):
import sys
bbn=1000000007
	


		
def main():
	a = int(input())
	s = input()
	ret=0
	for ci,cj,ck in zip(s,s[1:],s[2:]):
		if (ci,cj,ck)==('A','B','C'):
			ret+=1
	print(ret)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
n = int(input())
s = input()
ans = 0

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

Solution (Python):
n = int(input())
a = list(input())
ans = 0
for i in range(n-2):
  if a[i]=='A' and a[i+1]=='B' and a[i+2]=='C':
    ans+=1
print(ans)

Solution (Python):
N = int(input())
S = input()[0:N]
print(S.count("ABC"))

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

Solution (Python):

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

result=0

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

print(result)

Solution (Python):
N=int(input())
S=input()
print(S.count("ABC"))

Solution (Python):
n=int(input())
s=list(input())
c=0
for i in range(len(s)):
    if s[i] == "A":
        try:
            if s[i+1]=="B":    
                if s[i+2]=="C":
                    c+=1
        except:
            pass
            
print(c)

Solution (Python):
N=int(input())
s=input()
S=list(s)

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

Solution (Python):
N=map(int,input())
s=input()
n=len(s)
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)

Solution (Python):


VALUE = 500

length = int(input())
chars = input().upper()

print(len(chars.split('ABC')) - 1)

Solution (Python):
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)

Solution (Python):
n = int(input())
str =input()

print(str.count("ABC"))

Solution (Python):
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)

Solution (Python):
N = int(input())
S = str(input())
print(S.count("ABC"))

Solution (Python):
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)

Solution (Python):
n=int(input())
s=str(input())
count=0
for i in range(n-2):
    if s[i:i+3] =='ABC':
        count+=1
print(count)

Solution (Python):
n = int(input())
s = list(input())
unko = 0
for i in range(2,n):
    if s[i] == "C" and s[i-1] == "B" and s[i-2]=="A":
        unko += 1
print(unko)

Solution (Python):
in1 = input()
in2 = input()

print(in2.count('ABC'))

Solution (Python):
n = int(input())
s = input()

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
def checkABC(S):
    count = 0
    for i in range(len(S)):
        if S[i] == 'A':
            if i+1 < len(S) and S[i+1] == 'B':
                if i+2 < len(S) and S[i+2] == 'C':
                    count += 1
    
    return count


N = int(input())

S = list(input())

print(checkABC(S))

Solution (Python):
N = int(input())
S = input()

print(S.count('ABC'))

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

Solution (Python):

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)

Solution (Python):
n = int(raw_input())
s = raw_input()
i = 1
print(s.count('ABC'))

Solution (Python):
import math
import sys


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


if N < 3:
    print(0)
    exit(0)

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

print(ans)
exit(0)

Solution (Python):
a = [input() for i in range(2)]

n = a[0]
s = a[1]

find = "ABC"

pos = 0
count = 0

for i in range(int(n)):
    pos = s.find(find)
    if(pos == -1):
        print(str(count))
        break
    else:
        count = count + 1
        s = s[pos+1:]

Solution (Python):
a = input()
string = input()
substring = "ABC"

count = string.count(substring)


print(count)

Solution (Python):
N = int(input())
S = str(input())
ans = 0

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

Solution (Python):
N = int(input())
S = str(input())
 
mycnt = 0
for i in range(N-2):
    
    if S[i] == 'A' and  S[i+1] == 'B' and  S[i+2] == 'C':
        mycnt += 1
print(mycnt)

Solution (Python):
length = int(input())
letter = input()

print(letter.count('ABC'))

Solution (Python):
a = int(input())
b = input()

print(b.count('ABC'))

Solution (Python):
N = int(input())
S = input()
print(S.count("ABC"))

Solution (Python):
n = input()
s = input().strip()
d = 0
for a,b,c in zip(s,s[1:],s[2:]):
    if a+b+c == "ABC":
        d+=1
print(d)

Solution (Python):
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)

Solution (Python):
n = int(input())
s = input()

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

print(count)

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

Solution (Python):
N = int(input())
S = input()

ans=S.count("ABC")
print(ans)

Solution (Python):
n = int(input())
s = input()
c = 0
for i in range(n):
    if s[i: i + 3] == 'ABC':
        c += 1
print(c)

Solution (Python):
n = int(input())
s = input()

moji = "ABC"
str = s[:(n)]

print(str.count(moji))

Solution (Python):

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

Solution (Python):
N = int(input())
S = input()

target = "ABC"
counter = 0
start = 0
for i in range(N):
    start = 1
    if (-1 != S.find(target)):
        counter += 1
        start = S.find(target) + 3
    S = S[start:]

print(counter)

Solution (Python):
n = int(input())
string = str(input())
print(string.count("ABC"))

Solution (Python):
n = int(input())
s = input()

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

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

Solution (Python):
N = int(input())
S = input()

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

print(result)

Solution (Python):
n = int(input())
s = str(input())
print(len(s.split("ABC")) - 1)

Solution (Python):
N = int(input())
S = str(input())
print(S.count("ABC"))

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

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

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

Solution (Python):
N = int(input())
S = str(input())
print(S.count('ABC'))

Solution (Python):
n = int(input())
s = input()
r = 0

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

print(r)

Solution (Python):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()

input=lambda: sys.stdin.readline().rstrip()
import fractions
gcd=fractions.gcd
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0
n=I()
s=input()

t=s.replace('ABC','0')
ans=t.count('0')

print(ans)

Solution (Python):
n = int(input())
moziretsu = input()
t = moziretsu.count('ABC')
print(t)

Solution (Python):
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)

Solution (Python):
n = int(input())
s = input()

print(s.count('ABC'))

Solution (Python):
N = int(input())
S = input()
count = S.count('ABC')
print(count)

Solution (Python):
N = int(input())
S = input()
count = 0
for n in range(len(S)-2):
    if S[n:n+3] == "ABC":
        count += 1
print(count)

Solution (Python):
n = int(input())
s = input()

print(s.count('ABC'))

Solution (Python):
import os
nyu = int(input())
mozi= input()
print(mozi.count('ABC'))

Solution (Python):
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(int(cnt))

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, S: str):
    count = 0
    for i in range(N-2):
        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))  
    S = next(tokens)  
    solve(N, S)


if __name__ == '__main__':
    main()

Solution (Python):
n = input()
s = input()
print(s.count("ABC"))

Solution (Python):
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
    else:
        continue

print(ans)

Solution (Python):
def f(S):
	N = len(S)
	c = 0
	for i in range(N):
		if S[i:i+3] == 'ABC':
			c+=1
	return c 

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

Solution (Python):
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 and S[i]=="A":
        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 and S[i]=="A":
        tmp_c = 1
    elif tmp_c == 2:
        tmp_c = 0
print(count)

Solution (Python):
N = int(input())
S = str(input())

cnt = 0

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


print(cnt)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

_,S = read().split()

answer = S.count(b'ABC')
print(answer)

Solution (Python):
n=int(input())
s=input()
a=0
if n>2:
    for i in range(0,n):
        if i<n-2 and s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
         a=a+1
print(a)

Solution (Python):
N = int(input())
K = str(input()).upper()
c = K.count("ABC")
print(c)

Solution (Python):
n = int(input())
s = list(input())

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)

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

Solution (Python):
a = int(input())
b = str(input())
print(b.count('ABC'))

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

Solution (Python):
n = input()
s = input()
count = 0
for i in range(1, int(n)-1):
    if s[i-1] + s[i] + s[i+1] == "ABC":
        count = count + 1
print(count)

Solution (Python):
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)

Solution (Python):
n = int(input())
s = input()
i = 0
ans = 0
while i < n:
  if s[i]=='A' and s[i:i+3]=='ABC':
    ans += 1
    i += 3
  else:
    i += 1
print(ans)

Solution (Python):
N = int(input())
S = input()

count = 0

s = S.split('ABC')
print(len(s) - 1)

Solution (Python):
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)

Solution (Python):
N = int(input())
print(input().count('ABC'))

Solution (Python):
import re

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

List = re.findall("ABC",s)
print(len(List))

Solution (Python):

import numpy as np

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

state = 0
ans = 0

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

print(ans)

Solution (Python):
N = int(input())
S = input()
total = 0
for i in range(0, N):
    if S[i:i+3] == "ABC":
        total += 1
    else:
        continue
print(total)

Solution (Python):
import re

Length = list(map(int, input().split()))
String = list(map(str, input().split()))

N = Length[0]
S = String[0]

same = re.findall("abc", S, re.IGNORECASE)

print(len(same))

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

Solution (Python):
def B():
    n = int(raw_input())
    s = list(raw_input())
    c = 0
    for i in range(0,len(s)-2):
        if str(s[i]) == "A":
            if str(s[i+1]) == "B":
                if str(s[i+2]) == "C":
                    c = c + 1
    print c

if __name__ == '__main__':
    B()

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

Solution (Python):
n = int(input())
s = input()

print(s.count('ABC'))

Solution (Python):
n = int(input())
s = input()+'x'

cnt = 0

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

print(cnt)

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

Solution (Python):
n =int( input())
s = input()

if (3<=n and n <=50) and (3<=len(s) and len(s) <=50):
    print(s.count("ABC"))
else:
    print("error")

Solution (Python):
N = int(input())
S = input()
count = 0

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

Solution (Python):
n=int(input())
x=input()
y=x.count("ABC")
print(y)

Solution (Python):
N = int(input())
S = input()

print(S.count('ABC'))

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

Solution (Python):
from collections import Counter

length = int(input())
string = input()

print(string.count('ABC'))

Solution (Python):
N = input()
S = input()


L = len(S)
SS = list(S) 
count = 0


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

print(count)

Solution (Python):
N=input()
S=input()

print(S.count("ABC"))

Solution (Python):
n = int(input())
s = input()

cnt = 0

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

print(cnt)

Solution (Python):
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):
		if S[cnt:cnt+3] == "ABC":
			ans += 1
		break
print(ans)

Solution (Python):
n=int(input())
s=input()


print(s.count("ABC"))

Solution (Python):
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)

Solution (Python):
n = input()
s = input()
a = "ABC"
print(len(s.split(a))-1)

Solution (Python):
N = int(input())
S = input()
print(S.count('ABC'))

Solution (Python):
N = int(input())
S = input()

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

print(res)

Solution (Python):
N = int(input())
S = str(input())

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

if __name__ == "__main__":
    main()

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

Solution (Python):
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)

Solution (Python):





N = int(input())
s = input()

c = s.count('ABC')
print(c)

Solution (Python):
n = input()
s = input()
if (len(s) == int(n)):
    print(s.count("ABC"))

Solution (Python):

import sys


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

    print(answer)
    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))  
    S = next(tokens)  
    solve(N, S)

if __name__ == '__main__':
    main()

Solution (Python):
n=input()
n=int(n)
s=input()

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

print(count)

Solution (Python):
N = input()
S = input()

if (len(S) == int(N)):
    print(S.count("ABC"))

Solution (Python):
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)

Solution (Python):
num = int(input())
string = input()

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

Solution (Python):
N = int(input())
S = input()
print(S.count('ABC'))

Solution (Python):
N = int(input())
S = str(input())

ct = S.count('ABC')

print(ct)

Solution (Python):
N = int(input())
S = input()
print(S.count("ABC"))

Solution (Python):
n = int(input())
s = input()

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

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

Solution (Python):


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

Solution (Python):
N = input()
S = input()

count = 0
result = 0
for s in S:
  if s == "A":
    count = 1
  elif count == 1 and s == "B":
    count += 1
  elif count == 2 and s == "C":
    count = 0
    result += 1
  else:
    count = 0
print(result)

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

Solution (Python):
from fractions import gcd

from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions


MOD = 10 ** 9 + 7



def lcm(a, b):
    return a * b / fractions.gcd(a, b)

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

Solution (Python):
n =input()
s = input()

a = s.count('ABC')

print(a)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
str_len = int(input())
string_sample = input()
sample = 'ABC'

counter = 0
for i in range(str_len - 2):
  if string_sample[i:i+3] == sample:
    counter += 1
    
print(counter)

Solution (Python):
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)

Solution (Python):
N = int(input())
S = list(input())
ans = 0
for i in range(N-2):
    if S[i:i+3] == ["A","B","C"]:
        ans += 1
print(ans)

Solution (Python):
n = input()
s = input()

print(s.count('ABC'))

Solution (Python):
n = int(input())
s = str(input())
count = 0
for i in range(n):
    if s[i] == 'a' or s[i] == 'A':
        if i + 1 < n:
            if s[i + 1] == 'b' or s[i + 1] == 'B':
                if i + 2 < n:
                    if s[i + 2] == 'c' or s[i + 2] ==  'C':
                        count += 1
print(count)

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

Solution (Python):
N=int(input())
S=input()

print(S.count('ABC'))

Solution (Python):
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)

Solution (Python):
N = int(input())
S = str(input())

C = S.count("ABC")

print(C)

Solution (Python):
n = int(input())
s = str(input())

s = s.replace('ABC','9')

cnt = 0
for i in range(len(s)):
  if s[i] == '9':
    cnt += 1
print(cnt)

Solution (Python):
N = int(input())
S = input()

print(S.count("ABC"))

Solution (Python):
N = int(input())
S = str(input())
print(S.count("ABC"))

Solution (Python):
n = int(input())
s = input()

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

print(ans)

Solution (Python):
n = int(input())
s = input()
counter = 0

while True:
    if "ABC" in s:
        s_list = s.split("ABC")
        counter = len(s_list) - 1
        break
    else:
        break

print(counter)

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

Solution (Python):
N = int(input())
S = input()

print(S.count('ABC'))

Solution (Python):
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)

Solution (Python):
n = int(input())
s = input()
print(s.count("ABC"))

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

Solution (Python):

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

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

Solution (Python):
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()

Solution (Python):
import sys
import copy
import bisect
import numpy as np
N=int(input())
s=input()
res=0
for i in range(N-2):
    if s[i:i+3]=='ABC':
        res += 1
print(res)

Solution (Python):
n = int(input())
s = input()
print(s.count("ABC"))

Solution (Python):
n=int(input())
s=input()
print(s.count("ABC"))

Solution (Python):
N = input()
S = input()

print(S.count("ABC"))

Solution (Python):
n=input()
s=input()

print(s.count('ABC'))

Solution (Python):
a = int(input())
b = list(input())
cnt=0
c=a-2
for i in range(c):
  if b[i]+b[i+1]+b[i+2] == "ABC":
    cnt += 1
    
print(cnt)

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

Solution (Python):


n = int(input())
s = list(input())
count = 0
hantei = True

for i in range(n):
    if s[i] == "A":
        try:
            if s[i+1]=="B" and s[i+2]=="C":
                count += 1
            else:
                continue
        except IndexError:
            break
    
print(count)

Solution (Python):
N = input()
S = input()
counter = 0

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

print(counter)

Solution (Python):
N = input()
S = input()

num = S.count('ABC')

print(num)

Solution (Python):
N = input()
S = input()

print(S.count('ABC'))

Solution (Python):
input()
print(input().strip().count("ABC"))

Solution (Python):
N = int(input())
S = input()
state = 0
ans = 0

def isABC(s):
    global state
    if state==0:
        if s=="A":
            state = 1
        return 0
    elif state==1:
        if s=="B":
            state = 2
        elif s=="A":
            state=1
        else:
            state=0
        return 0
    else:
        if s=="C":
            state=0
            return 1
        elif s=="A":
            state=1
            return 0
        else:
            state=0
            return 0

for i in S:
    ans += isABC(i)
print(ans)

Solution (Python):

s = [input() for i in range(2)]
N = int(s[0])
S = s[1]

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

Solution (Python):
c=input()
a = input()
b = a.count('ABC')
print(b)

Solution (Python):
N = int(input())
S = str(input())
print(S.count("ABC"))

Solution (Python):
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)

Solution (Python):
n = int(input())
a = input()
count = 0

for i in range(2, n):
  if a[i-2]+a[i-1]+a[i] == "ABC":
    count += 1
print(count)

Solution (Python):
n = int(input())
s = input()
print(s.count("ABC"))

Solution (Python):
N=int(input())
S=input()

print(int((N-len(S.replace('ABC','')))/3))

Solution (Python):
n = int(input())
s = input()
res = 0

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

print(res)

Solution (Python):
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)

Solution (Python):
n = int(input())
s = input()

print(s.replace("ABC", "a").count("a"))

Solution (Python):
N = int(input())
S = input()

sum = 0
a = 0
b = 0

for i in range(N):
    if(S[i] == 'A'):
        a = 1
        b = 0
    elif(S[i] == 'B' and a == 1):
        b = 1
        a = 0
    elif(S[i] == 'C' and b == 1):
        sum = sum + 1
        a = 0
        b = 0
    else:
        a = 0
        b = 0


print(sum)

Solution (Python):
x = input()
mes = input()
print(mes.count('ABC'))

Solution (Python):
n = int(input())
s = str(input())

cnt = 0
for i,v in enumerate(s):
    if i == n-2:
        break
    chunk = s[i]+s[i+1]+s[i+2]
    if chunk == 'ABC':
        cnt += 1
print(cnt)

Solution (Python):
n = int(input())
st = input()
m = ["A","B","C"]
c = 0
t = 0
for i in range(n-2):
  if st[i] == "A" and st[i+1] == "B" and st[i+2] == "C":
    c += 1
    
 
print(c)

Solution (Python):
N = int(input())
S = str(input())
print(S.count("ABC"))

Solution (Python):
n=int(input())
s=input()
i=0
ans=0
while i<=n-3:
    if(s[i:i+3]=="ABC"):
        ans+=1
    i+=1    
print(ans)