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):
N = int(input())
S = str(input())
ctr = 0

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

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()
print(s.count('ABC'))

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):
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]



def A():
    K, X = LI()
    if K * 500 >= X:
        print("Yes")
    else:
        print("No")
    return



def B():
    n = I()
    s = S()
    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)
    return



def C():
    return



def D():
    return



def E():
    return



def F():
    return



if __name__ == "__main__":
    B()

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

Solution (Python):
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')


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

ans = 0
i = 0
while i < N:
    if S[i] == "A":
        if i +1 < N:
            i += 1
            if S[i] == "B":
                if i + 1 < N:
                    i += 1
                    if S[i] == "C":
                        ans += 1
                        if i + 1 < N:
                            i+=1
                        else:
                            break
                    else:
                        continue
                else:
                    break
            else:
                continue
        else:
            break
    else:
        i += 1
        continue


print(ans)

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

count = 0
if d < 3:
    print(0)
else:
	for i in range(d-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()

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

Solution (Python):
n=int(input())
S=list(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):
from sys import stdin
lines = stdin.readlines()
 
N = int(lines[0])
S = lines[1]

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

print(cnt)

Solution (Python):


Num = int(input())
Str = input()

Ans = Str.count("ABC")

print(Ans)

Solution (Python):
n = int(input())
s = list(input())
c = 0
x = []
for i in s:
    x.append(i)
    if "".join(x) == "ABC":
        c += 1
    if len(x) == 3:
        del x[0]
print(c)

Solution (Python):
import re

N=input()
S=input()

pattern = 'ABC'
result = re.findall(pattern, S, re.S)

print(len(result))

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

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

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

counts=0

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

Solution (Python):
from sys import stdin

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=int(input())
S=input()
print(S.count("ABC",0,N))

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

Solution (Python):
n=int(input());s=input();print(len([i for i in s.replace("ABC","

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

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

Solution (Python):
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, s = [input() for i in range(2)]
n = int(n)
words = [w for w in s]

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

print(cnt)

Solution (Python):
def my_count(string, substring):
    string_size = len(string)
    substring_size = len(substring)
    count = 0
    for i in range(0,string_size-substring_size+1):
        if string[i:i+substring_size] == substring:
            count+=1
    return count
N = input()
S = input()
print(my_count(str(S), 'ABC'))

Solution (Python):
n = int(input())
s = input().replace("ABC", "")

print((n - len(s))// 3)

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

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

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:i+3] == "ABC"):
        count += 1

print(count)

Solution (Python):
n = input()
S = input()
c = 0
for i in range(len(S)-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 = str(input())

print(S.count('ABC'))

Solution (Python):
l = int(input())
s = input()
j = 0

for i in range(0,l-2):
  if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
    j=j+1
    
print(j)

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

print(out)

Solution (Python):
input()
x = input()
ans = x.count("ABC")
print(ans)

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

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

i = 0
ans = 0

while i < len(s) - 2:
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":
        ans += 1
        i += 3
    else:
        i += 1
print(ans)

Solution (Python):
import numpy as np

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

    print(S.count("ABC"))

    return 0

if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
s = str(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()
a = 0

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

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

print(s.count('ABC'))

Solution (Python):
n = int(input())
s = input()
count = 0
result = 0
for c in list(s):
  if count == len(s)-2:
    break
  elif c == "A":
    judge = s[count:count+3]
    if judge == "ABC":
      result += 1
  count += 1
      
print(result)

Solution (Python):
N = input()
s = list(str(input()))

count = 0

for i in range(len(s)-2):
    str = s[i]+s[i+1]+s[i+2]
    if(str=="ABC"):
        count += 1

print(count)

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

count = 0

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

print(count)

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

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

print(count)

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):
N = int(input())
S = input()
ans = 0
i = 0
while True:
  if S[i:i+3] == 'ABC':
    ans += 1
    i += 3

  else:
    i += 1
  
  if i >= N:
    break

print(ans)

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

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

res = 0
phase = 0
for c in s:
    if c == "A":
        phase = 1
    elif c == "B" and phase == 1:
        phase = 2
    elif c == "C" and phase == 2:
        phase = 0
        res += 1
    else:
        phase = 0

print(res)

Solution (Python):
N = int(input())
S = input().rstrip("\n")

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

print(answer)

Solution (Python):





input1=input()
input2=input()

N=int(input1)
S=input2

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)

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

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

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

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

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

if __name__ == "__main__":
    main()

Solution (Python):
length = int(input())
string = input().split("ABC")
print(len(string) - 1)

Solution (Python):
input1 = input()
input2 = input()

N = int(input1)
S = input2

result = 0

while True:

    if "ABC" in S:
        S = S.replace("ABC", "X",1)
        result += 1
    else:
        break
    
print(result)

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

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

print(s.count('ABC'))

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

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

nums = 0
jmp = 0

for x,a in enumerate(s):
  if jmp!=0:
    jmp -= 1
    continue

  if x>len(s)-3:
    break
  if a=='A':
    if s[x+1]=='B' and s[x+2]=='C':
      nums += 1
      jmp = 2

print(nums)

Solution (Python):

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

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

cnt = 0
ans = 0
for i in s:
    if i == 'A':
        cnt = 1
        
    elif i == 'B' and cnt == 1:
        cnt = 2
        
    elif i == 'C' and cnt == 2:
        cnt = 3
        
    else:
        cnt = 0
    if cnt == 3:
        ans += 1

print(ans)

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

Solution (Python):
n = int(input())
s = input()
count = 0
t = s.replace("ABC", "a")
for i in t :
    if i == "a" :
        count += 1

print(count)

Solution (Python):

N = int(input())
S = input()
count = 0
while 'ABC' in S:
    count += 1
    S = S.replace("ABC", "", 1)

print(count)

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

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

first = s_L[0]
second = s_L[0]
third = s_L[1]

ans = 0

for i in range(n-2):
    first = second
    second = third
    third = s_L[i+2]
    
    if first == "A" and second == "B" and third == "C":
       ans += 1
    

    
    
print(ans)

Solution (Python):



import pdb
import sys
F = sys.stdin

N = int(F.readline().rstrip())
S = F.readline().rstrip()
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)

Solution (Python):
N = int(input())
S = input()
T = 0
for x in range(N):
    if S[x:x+3] == "ABC":
        T += 1
print(T)

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().split("ABC")
num = 0
for i in range(len(s)):
    num_s = len(s[i])
    num += num_s
print((n-num)//3)

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

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

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

print(ans)

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()
ans=0
c=0
for s in S:
    
    if s=="A":
        c=1
    elif s=="B" and c==1:
        c=2
    elif s=="C" and c==2:
        ans+=1
        c=0
    else:
        c=0

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 = str(input())

a = 0
for i in range(n-2):
    if ((s[i] == "A") & (s[i + 1] == "B")) & (s[i + 2] == "C"):
        a += 1
    else:
        continue
    

print(a)

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):
inputA= int(input())
inputB =input()

print(inputB.count('ABC'))

Solution (Python):
N=int(input())
S=input()
pre='X'
prepre='X'
ans=0

for i in range(N):
    if S[i]=='C' and pre=='B' and prepre=='A':
        ans+=1
    prepre=pre
    pre=S[i]
    
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()

print(s.count('ABC'))

Solution (Python):


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n = int(input())


s = input()

print(s.count("ABC"))

Solution (Python):
A=int(input())
B=input()
print(B.count("ABC"))

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

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

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

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

Solution (Python):
import sys
N=int(input())
S=sys.stdin.readline()
stat=0
count=0
for ele in S:
    if ele=='A':
            stat=1
    else:
        if stat == 1:
            if ele=='B':
                stat=2
            else:
                stat=0
        elif stat==2:
            if ele=='C':
                stat=0
                count+=1
            else:
                stat=0
print(count)

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):
input()
s = input()
a = ("ああ"+s+"ああ").split("ABC")
print(len(a) - 1)

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 = int( input() ) ;
S = input().strip() ;

c = 0 ;
for x in range ( N ) :
	if x + 3 > len(S ) : break ;
	if S[x:x+3] == "ABC" :
		c += 1 ; 
print ( c ) ;

Solution (Python):
input()
print(input().count('ABC'))

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

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

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

print(S.count('ABC'))

Solution (Python):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
s = input()
ans = 0
for i in range(n):
    if s[i] == "A" and s[i+1:i+3] == "BC": ans += 1
print(ans)

Solution (Python):
def main():
    N = int(input())
    S = str(input())
    
    if 'ABC' in S :
        C = S.split('ABC')
        
        print (str(len(C)-1))
    else :
        print ('0')


if __name__ == '__main__':
    main()

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

print(s.count('ABC'))

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):
N = int(input())
S = 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=input()
S=input()
print(S.count("ABC"))

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

if __name__=='__main__':
    main()

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

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

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

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

Solution (Python):
n = int(input())
s = list(input())
i = 0
a = 0
while i < n-2:
  if s[i] == "A":
    i += 1
    if s[i] == "B":
      i += 1
      if s[i] == "C":
        i += 1
        a += 1
  else:
    i += 1
print(a)

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

Solution (Python):
import re

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


print(len(re.findall('ABC', S)))

Solution (Python):
import sys


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

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

    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
S = input().strip()

ans = S.count('ABC')

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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


if __name__=='__main__':
    main()

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

print(S.count('ABC'))

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

print(c)

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

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

Solution (Python):
ans=0
n=input()
s=input()
flag="0"

for i in s:
    if i=="A":
        flag="a"
    elif i=="B" and flag=="a":
        flag="b"
    elif i=="C" and flag=="b":
        flag="0"
        ans+=1
    else:
        flag="0"
        
print(ans)

Solution (Python):
import re

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

r = re.compile("ABC")

l = r.findall(S)

print(len(l))

Solution (Python):
N = input()

S = input()

print(S.count('ABC'))

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

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

print(count)

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

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

print(count)

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

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

cnt = 0
flg = 0
for i in range(N):
  if s[i] == "A":
    flg = 1
  elif flg == 1 and s[i] == "B":
    flg = 2
  elif flg == 2 and s[i] == "C":
    flg = 0
    cnt += 1
  else:
    flg = 0

print(cnt)

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

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

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

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

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

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

print(count)

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

Solution (Python):


from sys import stdin

N = int(stdin.readline())
S = stdin.readline().strip()

ret = 0
while 'ABC' in S:
    ret += 1
    i = S.index('ABC')
    S = S[i+1:]
print(ret)

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

print(a)

Solution (Python):
n=int(input())
s=str(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()
print(s.count('ABC'))

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

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

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

print(ans)

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

count=0

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

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

result = S.count('ABC')
print(result)

Solution (Python):
import re

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

repeater = re.compile('ABC')
result = repeater.findall(s)
print(len(result))

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

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

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



if __name__ == '__main__':
    AtCoder().main()

Solution (Python):
A = input()
B = input()
a = int(A)
print(B.count("ABC"))

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

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

print(s.count('ABC'))

Solution (Python):



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

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

print(c)

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

n = int(readline())
s = readline().decode("utf-8")

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

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

Solution (Python):
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 = cnt + 1
print(cnt)

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

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



test = ""

"""
33
ABCCABCBABCCABACBCBBABCBCBCBCABCB
"""

test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()


n = int(input2())
s = input2()

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

print(ans)

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

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

Solution (Python):
N = int(input())
S = input()
cnt = 0
ans = 0
for i in range(N):
    if S[i] == "A":
        if cnt == 0:
            cnt += 1
        else:
            cnt = 1
    if S[i] == "B":
        if cnt == 1:
            cnt += 1
        else:
            cnt = 0
    if S[i] == "C":
        if cnt == 2:
            ans += 1
            cnt = 0
        else:
            cnt = 0

print(ans)

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

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

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

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

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

Solution (Python):
import sys

def resolve():
    input = sys.stdin.readline
    N=int(input().rstrip())
    S=input().rstrip()

    count=0
    buf2=""
    buf1=""
    for i in range(N):
        buf0=S[i]

        if buf2=="A" and buf1=="B" and buf0=="C":
            count+=1
        buf2=buf1
        buf1=buf0
        
    print(count)

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """10
ZABCDBABCQ"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """19
THREEONEFOURONEFIVE"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """33
ABCCABCBABCCABACBCBBABCBCBCBCABCB"""
        output = """5"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

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):
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


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

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

ans = 0
tmp = 0

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

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

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

S = S.upper()

c = S.count('ABC')

print(c)

Solution (Python):
N = int(input())
S = list(input())
ans = 0
for i in range(N):
  if i <= N - 3:
    if "".join(S[i:i + 3]) == "ABC":
      ans += 1
  else:
    break
print(ans)

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

i = 0
ans = 0
while i <= n:
    if s[i:i+3] == "ABC":
        ans += 1
        i += 3
    else:
        i += 1

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(0, N-2):
    
    if S[i:i+3] == "ABC":
        count += 1

print(count)

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

Solution (Python):
n = int(input())
s = input()
cnt = 0
abc = ""
for c in s:
    
    if c == "A":
        abc = "A"
    elif c == "B" and abc == "A":
        abc ="B"
    elif c == "C" and abc == "B":
        cnt += 1
        abc = ""
    else:
        abc = ""
print(cnt)

Solution (Python):
N = int(input())
S = input().replace("ABC", "0")

print(S.count("0"))

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(n-2):
    if s[i]=='A':
        if s[i+1]=='B' and s[i+2]=='C':
            cnt+=1
print(cnt)

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