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 = input()
x = list(s)
y = 0
a = 0
while y <= n - 3:
  z = x[y] + x[y + 1] + x[y + 2]
  if z == "ABC":
    a += 1
    y += 1
  else:
    a += 0
    y += 1
print(a)

Solution (Python):


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

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

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

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

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

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

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

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 = str(input().upper())[:N]
number = S.count('ABC')
print(number)

Solution (Python):

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

i=N-1
result=0


while True:
    if i-2<0:
        break
    if S[i]=='C' and S[i-1]=='B' and S[i-2]=='A' :
        result+=1
    i-=1

print(result)

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

A_index = [i for i, x in enumerate(s) if x == 'A']

count = 0
for j in A_index :
  if j != n-1 and s[j+1] == 'B' :
    if j != n-2 and s[j+2] == 'C' :
      count += 1

print(count)

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

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

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

A_index = [i for i, x in enumerate(s) if x == 'A']

count = 0
for j in A_index :
  if j != n-1 :
    if s[j+1] == 'B' :
      if j != n-2 :
        if s[j+2] == 'C' :
          count += 1

print(count)

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

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())
print(S.count("ABC"))

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

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

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

Solution (Python):



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

Solution (Python):
import sys

ans = 0
input = sys.stdin.readline
N = int(input())
S = input().rstrip()

list_S = list(S)

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

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(0,n):
    if s[i] == "A":
        if i+2 <= n-1:
            if s[i+1] == "B" and 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()

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

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

count = 0

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

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

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

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

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

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

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

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

Solution (Python):
import re

a = input()
line = input()

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

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

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

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

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

Solution (Python):

import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline

n = int(input())
s = input().rstrip()
print(s.count("ABC"))

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

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

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

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

Solution (Python):


n = int(input())
S = list(input())

count = 0
count_total = 0
for moji in S:
    if moji == 'A':
        count = 'A'
    elif count == 'A' and moji == 'B':
        count = 'B'
    elif count == 'B' and moji == 'C':
        count = 0
        count_total += 1
    else:
        count = 0
    
print(count_total)

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

state = 0
count = 0


for i in range(len(S)):
    if S[i] == 'A':
        state = 1
    elif state == 1 and S[i] == 'B':
        state = 2
    elif state == 2 and S[i] == 'C':
        count += 1; state = 0
    else:
        state = 0
print count

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

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

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

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

cnt = 0
for i in range(N - 2):
    if S[i:].startswith('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=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):
input()
print(input().count("ABC"))

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

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

Solution (Python):
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


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


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


def sosu(x):
    for i in range(2, int(sqrt(x)+1)):
        if x % i == 0:
            return False
    return True


mod = 1000000007
inf = float('INF')


def A():
    K, X= LI()

    if (500*K>=X):
        print('Yes')
    else:
        print('No')


    return




def B():
    N=II()
    S=input()
    ans=0
    s=0
    for i in S:
        if (i=="A" and S[s+1]=='B' and S[s+2]=='C'):
            ans+=1
        s+=1
    print(ans)



    return




def true():
    S = input()
    S = S[:-1]

    tmp = 0
    for x in range(1 << (len(S)-1)):
        func = S[-1]
        for i in range(len(S)-1):
            if(x & (1 << i)):
                tmp += int(func)
                func = S[-2-i]
            else:
                func = S[-2-i]+func
        tmp += int(func)
    print(tmp)

    return


def flagcounter(x):
    if (x == 0):
        return 0
    return flagcounter(x >> 1)+(x & 1)

def jisyo(P):
    i=1
    S = sorted(P)
    X=0
    N=len(P)
    for p in P:
    
        X+=((S.index(p)+1) * (math.factorial(N-i)))-1
        
        S.remove(p)
        if len(S)==1:
            break
        i+=1
    return X

def C():
    N=II()
    P=LI()
    Q=LI()

    X=jisyo(P)
    Y=jisyo(Q)


    print(abs(X-Y))
        
    return



def D():
    N, K = LI()
    R, S, P = LI()
    T=list(input().rstrip())
    ans = 0
    for j in range(K):
        if T[j] == 'r':
            ans += P
        if T[j] == 'p':
            ans += S
        if T[j] == 's':
            ans += R
    j = 0
    rps=['r','p','s']

    for i in range(K, N):
        if T[j] == T[i]:
            if i+K>=N:
                j += 1
                continue
            T[i]=rps[rps.index(T[i+K])-1]
            j += 1
            continue
        if T[i] == 'r':
            ans += P
        if T[i] == 'p':
            ans += S
        if T[i] == 's':
            ans += R
        j += 1
    print(ans)
    return


def Dsyakutori():

    N, K = LI()
    A = LI()
    MAX = sum(A)
    if MAX < K:
        print(0)
        return
    Temp = MAX
    ans = 1
    for i in range(N):
        Temp = Temp-A[i]
        if (Temp >= K):
            ans += 1
        else:
            T = Temp+A[i]
            break
    Temp = T
    ckeep = N
    for k in range(N):
        c = N-1
        i -= 1
        Temp = T

        for j in range(N):
            Temp = Temp-A[c]
            if (Temp >= K):
                ans += 1

            elif(c < ckeep and i >= 0):
                ans += i
                ckeep = c
                break
            else:
                ckeep = c
                break
            c -= 1
        if i < 0:
            break
        T = T+A[i]
    print(ans)

    return




def E():
    N, M= LI()
    A = LI()
    A.sort(reverse=True)
    B=[0]*(N+1)
    for i in range(1,N+1):
        B[i]=B[i-1]+A[i-1]
    D=[0]*(2*10**5+1)
    for i in range(N):
        D[A[i]]+=1
    for i in range(len(D)-1,0,-1):
        D[i-1]+=D[i]
    l=-1
    r=2*10**5+1
    while r-l>1:
        m=(l+r)//2
        s=0
        for i in range(N):
            s+=D[max(1,m-A[i])]
        if s>=M:
            l=m
        else:
            r=m
    ans=0
    s=0
    for i in range(N):
        v=max(0,r-A[i])
        t=max(0,min(D[v],M-s))
        ans+=B[t]+t*A[i]
        s+=t
    ans+=l*(M-s)
    print(ans)

    
    return




def F():
    N, M = LI()

    value = [0] * M
    power = [0] * M
    for i in range(M):
        a, b = LI()
        value[i] = a
        c = LI()
        L = ['0'] * N
        for k in c:
            L[k - 1] = '1'
        bint = ''.join(L)
        power[i] = int(bint, 2)
    bint = ''.join(list(['1'] * N))
    dp = [inf] * (int(bint, 2)+1)
    t = 0
    cost = 0

    dp[0] = 0
    for s in range(int(bint, 2) + 1):
        for i in range(M):
            t = s | power[i]
            cost = dp[s] + value[i]
            dp[t] = min(dp[t], cost)
    print(-1) if(dp[-1] == inf) else print(dp[-1])

    return

    



def solution(S):
    
    N = len(S)

    pass



if __name__ == '__main__':

    B()

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

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):
a = input()
b = input()
print(b.count('ABC'))

Solution (Python):
Input1 = int(input())
N = Input1
Input2 =str(input())
ar = list(Input2)


roop = N - 2
chk_ar=[]
crt = ['A','B','C']

cnt =0
for i in range(roop):
  chk_ar.append(ar[i])
  chk_ar.append(ar[i+1])
  chk_ar.append(ar[i+2])

  if chk_ar == crt:
    cnt+=1
  
  chk_ar=[]

print(cnt)

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

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

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

print(ans)

Solution (Python):
num = input()
char = input()

print(char.count("ABC"))

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

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

Solution (Python):
import collections

N = 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 = list(input())
num = 0
for i in range(n-2):
    if(s[i]=='A'and s[i+1]=='B' and s[i+2]=='C'):
        num += 1
    else:
        pass
print(num)

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

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

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

Solution (Python):
length_count = int(input())
strings = input()

abc_count = 0
a = False
b = False

strings_list = list(strings)

for i in range(length_count):
    
    if strings_list[i] == 'A':
        a = True
        b = False

    elif strings_list[i] == 'B' and a:
        if b:
            a = False
            b = False
        b = True
        
    elif strings_list[i] == 'C' and a and b:
        abc_count += 1
        a = False
        b = False
    else:
        a = False
        b = False

print(abc_count)

Solution (Python):
abc = 'ABC'
N = int(input().rstrip())
S = input().rstrip()
ret = 0
if N == 3 and S == abc:
    ret = 1
else:
    for i in range(N - len(abc) + 1):
        if abc == S[i:i+3]:
            ret += 1
print(ret)

Solution (Python):
input()
text = input().split("ABC")
print(len(text)-1)

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

Solution (Python):
num = int(input())
str = input()
str.split(" ")
result = 0
for n in range(1, num - 1):
    if str[n-1] == 'A' and str[n] == 'B' and str[n+1] == 'C':
        result += 1
print(result)

Solution (Python):
N = int(input())
S = input()
mae = ["","",""]
s = 0
for i in range(N):
    del mae[0]
    mae.append(S[i])
    if mae == ["A","B","C"]:
        s += 1
print(s)

Solution (Python):
N = int(input())
S = str.upper(input())
import re
t = re.findall('ABC', S)
print(len(t))

Solution (Python):
a = int(input())
b = input()
ans = 0
for i,j,k in zip(b,b[1:],b[2:]):
    if i+j+k == 'ABC':ans+=1

print(ans)

Solution (Python):
hoge = [0 for i in range(2)]

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

print(S.count('ABC'))

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

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

cnt = 0

while S.find("ABC") >= 0:
    f = S.find("ABC")
    S = S[f + 2 : ]
    cnt += 1
    
print(cnt)

Solution (Python):


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


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

print(count)

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

S = NS[1]

print(S.count('ABC'))

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

res = 0

for i in range(N-2):
  tmp = S[i:i+3]
  if str.upper(tmp) == "ABC":
    res += 1
    
print(res)

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

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

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

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(2,n):
  if s[i-2:i+1] == "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):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
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 LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = input()
    print(s.count("ABC"))
    return


if __name__ == "__main__":
    solve()

Solution (Python):
total = int(input())
text = input()

res = 0

if total >= 3:
    for x in range(0, total - 1):
        if text[x] == "A":
            if x + 3 <= total:
                if text[x + 1] == "B" and text[x + 2] == "C":
                    res += 1

print(res)

Solution (Python):
a = input()
b = input()
index = 0
find = "ABC"
count = 0

while index < int(a):
    i = b[index:].find(find)
    if i == -1:
        break
    index += i + 3
    count += 1

print(count)

Solution (Python):
import re
n=int(input())
s=input()
m = re.finditer(r"ABC", s)
c=[]
for i in m:
    c.append(m)
print(len(c))

Solution (Python):
N = int(input())
S = input()
ans = 0
i = 0
while i <= N-3:
    if S[i:i+3] == 'ABC':
        ans += 1
        i += 3
    else:
        i += 1
print(ans)

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

T = S.replace('ABC','')
print((len(S)-len(T))//3)

Solution (Python):

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)

Solution (Python):
import sys


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

sys.exit()

Solution (Python):
import sys


def main():
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline()
    print(s.count("ABC"))

if __name__ == "__main__":
    main()

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

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

print(ans)

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

Solution (Python):
N,S=[input() for i in range(2)]
print(S.count("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()

print(s.count("ABC"))

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

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

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

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

Solution (Python):
EXP_STR="ABC"

n = int(input())
input_str = input()

print(input_str.count(EXP_STR))

Solution (Python):
"""
https://atcoder.jp/contests/abc150/tasks/abc150_b
"""
import numpy as np


def calc(N: int, S: str) -> int:
    return S.count("ABC")


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    N, = load_input_as_int_array()
    S = input()
    result = calc(N, S)
    print(result)


main()

Solution (Python):
num = int(input())
s=list(input())
ss = 0

for i in range(num):
  if "A" == s[i]:
    if i > num - 3:
      break
    if "B" == s[i + 1]:
      if "C" == s[i + 2]:
        ss += 1
print(ss)

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

print(S.count("ABC"))

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

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

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


count = 0

while S.find('ABC') > -1:
    count += 1
    n = S.find('ABC')
    S = S[n+3:]

print(count)

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()
c=0
for i in range(n-2):
	if s[i:i+3]=='ABC':
		c+=1
print(c)

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

print(S.count('ABC'))

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

p = 0
res = 0

for e in s:
    if e == 'A':
        p = 1
    elif p == 1 and e == 'B':
        p += 1
    elif p == 2 and e == 'C':
        p = 0
        res += 1
    else:
        p = 0
print(res)

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

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

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

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

Solution (Python):
n = 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()
if len(S) == N:
  if (N >= 3) and (N <= 50):
    if S.isupper() == True:
      print(S.count("ABC"))

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

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

check = ['A', 'B', 'C']

count = 0
state = 0

for i in range(len(s)):
    c = s[i]
    if c != check[state]:
        if c == check[0]:
            state = 1
        else:
            state = 0
        continue
    
    state += 1
    if state == 3:
        count += 1
        state = 0

print(count)

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

print(S.count("ABC"))

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

Solution (Python):
n,s=open(0);print(s.count('ABC'))

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

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

a = 0

for n in range(N - 2):
  if List[n] == 'A':
    if List[n + 1] == 'B':
      if List[n + 2] == 'C':
        a += 1
        
print(a)

Solution (Python):
N = input()
S = input()
count = 0
if(int(N)>=3 and int(N)<=50):
    for i in range(1, int(N)-1):
        if S[i-1]+S[i]+S[i+1] == "ABC":
            count += 1
    print(count)

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

print(count)

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):
  if (s[i:i+3] == "ABC"):
    ans += 1
print(ans)

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

Solution (Python):
num = int(input())
bunsyo = input()
count = 0

for i in range(len(bunsyo)):
  if i+2 > num-1:
    continue
  if bunsyo[i] == 'A':
    if bunsyo[i+1] =='B':
      if bunsyo[i+2] == 'C':
        count = count + 1
print(count)

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

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

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

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

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

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] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
    ans += 1

print(ans)

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

result = re.findall(r'ABC', s)
print(len(result))

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

s = str(input())

A = "ABC"

ans = int(0)

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

print(ans)

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

Solution (Python):
num = int(input())
word = input()
if len(word) >= num:
    print(word[0:num].count('ABC'))
else:
    print(0)

Solution (Python):
N = int(input())
S = input()
if len(S) <= N:
    print(S.count("ABC"))
else:
    print()

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

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

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

print(counter)

Solution (Python):
import re
N=int(input())
S=input()
A=re.findall("ABC",S)
print(len(A))

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

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

Solution (Python):
l = [input() for i in range(2)]
print(l[1].count("ABC"))

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