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

count = 0
for i in range(1, len(s)-1):
    if s[i-1]=='A' and s[i]=='B' and s[i+1]=='C':
        count += 1
    else:
        pass

print(count)

Solution (Python):
input_num = input()
input_str = input()

print(input_str.count('ABC'))

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

ABC = 'ABC'

do = lambda x, acc: do(x.replace(ABC, "", 1), acc + 1) if ABC in x else acc

print(do(s, 0))

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

print(s.count('ABC'))

Solution (Python):
def resolve():
    import re
    n = int(input())
    a = input()
    b = re.sub("ABC", "0", a)
    ans = 0
    for i in b:
        if i=="0":
            ans += 1
    print(ans)
resolve()

Solution (Python):

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

print(s.count("ABC"))

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

ans = S.count("ABC")

print(ans)

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

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()
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()
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
input = sys.stdin.readline

def main():
    N = int(input())
    s = input().strip()

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

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

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

res = 0
for i in range(len(S)-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())
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()
Y=len(S.replace("ABC",""))
print((N-Y)//3)

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

Solution (Python):
import math
from collections import deque
def main():
    n = int(input())
    s = input()

    print(s.count("ABC"))

if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
S=input()
s2='ABC'

print(S.count('ABC'))

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

ans = 0
str_list = list(S)

for i in range (len(str_list)-2):
  if(str_list[i] == "A"):
    if(str_list[i+1] == "B"):
      if(str_list[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] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
        ans += 1
print(ans)

Solution (Python):
n = int(input())
s = input()
pat = "ABC"

ans = 0
i = 0
while i < n:
    if pat == s[i : i + len(pat)]:
        ans += 1
    i += 1

print(ans)

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

S = list(S)
isA = False
isB = False
count = 0

for i in S:
    if i == 'A':
        isA = True
        isB = False
    elif i == 'B' and isA:
        isA = False
        isB = True
    elif i == 'C' and isB:
        count += 1
        isA = False
        isB = False
    else:
        isA = False
        isB = False
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()

print(s.count('ABC'))

Solution (Python):
N=int(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()
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())
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):
def main():
    N = int(input())
    S = input()

    print(S.count("ABC"))

if __name__ == "__main__":
    main()

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

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

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

INF = 1001001001

def resolve():
  n = int(input())
  s = input()
  print(s.count('ABC'))

  return

if __name__ == "__main__":
    resolve()

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 = 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()
print(len(re.findall(r'ABC', s)))

Solution (Python):

"""
Created on Wed Mar  4 00:15:23 2020

@author: Kanaru Sato
"""

N = int(input())
S = input()
target = "ABC"

count = 0

for i in range(0,N-2):
    if S[i:i+3] == target:
        count += 1
        
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" and S[i+2] == "C":
      count += 1
      
print(count)

Solution (Python):
N, S = [input() for _ in range(2)]
ABC = 0
loop = ['', '', '']
for i in range(int(N)):
  loop = loop[1:]
  loop.append(S[i])
  if loop == ['A', 'B', 'C']:
    ABC += 1
print(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" and S[i+1] == "B" and S[i+2] == "C":
    cnt += 1
    
print(cnt)

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

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

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

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

Solution (Python):
n=int(input())
l=input()
cnt=0
if n<=2:
  print(0)
  exit()
for i in range(n-2):
  if l[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 = list(input())
c = 0
for i in range(N-2):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                c += 1
print(c)

Solution (Python):
N = int(input())
S = input()
count = 0
for i in range(2,len(S)):
    if S[i-2] == "A" and S[i-1] == "B" and S[i] == "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):
    if S[i:i+3] == "ABC":
        count +=1
    else:
        pass
print(count)

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

Solution (Python):
n = int(input())
letters = map(str, input())
target = str()
ans = int()
for l in letters:
    if len(target) == 3:
        target = target[1:]
    target = target + l
    if target == 'ABC':
        ans += 1
print(ans)

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

Solution (Python):
def main(n,s):
    count = 0
    for i in range(n-2):
        if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
            count += 1
    return count

n = int(input())
s = list(input())
print(main(n,s))

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

Solution (Python):







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

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

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

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

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

print(S.count("ABC"))

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

ans = (len(s)-len(s.replace('ABC', ''))) // 3
print(ans)

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

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

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

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

print(answer)

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

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

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

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  
def grid(n): return [s_list() for _ in range(n)]


def main():

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

if __name__ == '__main__':
    main()

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

print(s.count('ABC'))

Solution (Python):
N = int(input())
S = input()
count = 0
while S and "ABC" in S:
    count += 1
    S = S.replace("ABC", "", 1)
print(count)

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

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

count = 0 

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

print(count)

Solution (Python):
import re
N = input()
S = input()
list = re.findall('ABC', S)
print(len(list))

Solution (Python):
import re

n = int(input())

s = input()

li = re.findall('ABC' , s)

ans = len(li)

print(ans)

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:i+3] == 'ABC':
        ans += 1

print(ans)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

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

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

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    input()
    S = input()
    print(S.count("ABC"))
    return


main()

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

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

print(ans)

Solution (Python):

import sys


def solve(N: int, S: str):
    ss = [S[i:(i+3)] for i in range(N-2)]
    ans = sum([1 for i, x in enumerate(ss) if x == 'ABC'])
    print(ans)



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 = 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()
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 + 1] == "B":
            if S[i + 2] == "C":
                ans += 1
print(ans)

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

i=0

for k in range(N-2):
	if A[k] =="A" and A[k+1]=="B" and A[k+2]=="C":
		i+=1
print(i)

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

Solution (Python):
n=int(input())
l=str(input())
print(l.count('A''B''C'))

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    print(str(readline().rstrip().decode('utf-8')).count("ABC"))


if __name__ == '__main__':
    solve()

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()
s=list(ss())
cnt=0
for i in range(n-2):

    if "".join(s[i:i+3])=="ABC":
        
        cnt+=1

print(cnt)

Solution (Python):
def main():
    n = int(input())
    s = input()
    abc = "ABC"
    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=int(input())
s=input()
ans=0
for i in range(len(s)):
  if i+2<len(s) and s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    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):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

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

ans = 0
pos = 0
while s.find("ABC", pos) != -1:
    ans += 1
    pos = s.find("ABC", pos)+1

print(ans)

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

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

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

print(c)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

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

Solution (Python):
import re 

n=int(input()) 
s=input().replace('ABC','1') 
s = re.sub(r"[A-Z]", "0", s) 
print(sum(list(map(int,list(s)))))

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


len = int(input().rstrip())
ans = input().rstrip().count("ABC")
print(ans)

Solution (Python):







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

    count = 0
    state = 0

    for c in S:
        if c == 'A':
            state = 1
        elif state == 1:
            if c == 'B':
                state = 2
            else:
                state = 0
        elif state == 2:
            if c == 'C':
                count += 1
            state = 0

    print(count)


main()

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

while True:
    if 'ABC' in s:
        s = s.replace('ABC', '', 1)
        count += 1
    else:
        break

print(count)

Solution (Python):
num=int(input())
moji=input()
ans=0

for i in range(num):
    if moji[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()
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(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())
K = list(str(input()))
count=0


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

print(count)

Solution (Python):
N = int(input())
S = input()
x = 0
y = 0
for i in range(N):
    if S[i]=='A':
        x = 1
    elif S[i]=="B" and x==1:
        x = 2
    elif S[i]=="C" and x==2:
        y+=1
        x = 0
    else:
        x = 0
print(y)

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

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

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

print(c)

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

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

print(cnt)

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

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

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

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

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

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

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

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

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

print(len([True for i, _ in enumerate(list(s)[0:-2]) if s[i:i + 3] == 'ABC']))

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

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

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

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

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

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

print(S.count("ABC"))

Solution (Python):
_=input()
print(input().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())
flag = False
sec_flag = False
c = 0
for si in s:
    if si == "A":
        flag = True
        sec_flag = False
    elif flag and si == "B":
        sec_flag = True
        flag = False
    elif sec_flag and si == "C":
        c += 1
        flag, sec_flag = False, False
    else:
        flag, sec_flag = False, False
print(c)

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

Solution (Python):
num_0 = int(input())
num_1 = input()
count = 0
count_i = 0

for i in range(0,num_0):
  if num_1[i] == "A":
    count_i = 1
  elif count_i == 1 and num_1[i] == "B":
    count_i = 2
  elif count_i == 2 and num_1[i] == "C":
    count = count + 1
    count_i = 0
  else:
    count_i = 0
    
print(count)

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

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

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()
ls = s.replace("ABC","")
print((n-len(ls))//3)

Solution (Python):

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

print(s.count("ABC"))

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

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

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

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

cnt=0
for i in range(len(S)):
  if S[i:i+3] == 'ABC':
    cnt += 1
print(cnt)

Solution (Python):
n = int(input())
print(input().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):
y=input()
x=input()
count=0
for k in range(len(x)-2):
  if (x[k]=='A') and (x[k+1]=='B') and (x[k+2]=='C'):
    count+=1
print(count)

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

t = 0

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

print(t)

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

print(s.count('ABC'))

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

A = 0
B = 0
res = 0
for i in range(N):
	if S[i] == 'A':
		A, B = 1, 0
	elif A == 1 and S[i] == 'B':
		A, B = 0, 1
	elif B == 1 and S[i] == 'C':
		A, B = 0, 0
		res += 1
	else:
		A, B = 0, 0
print(res)

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

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

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

print(cnt)

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

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

ans = 0

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

print(ans)

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

ABCsp = S.split('ABC')
ABCsp = ''.join(ABCsp)
print(int(len(S)-len(ABCsp)) // 3)

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

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

print(S.count("ABC"))

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

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):
    if S[i]=="A" and S[i+1:i+3]=="BC":
        c+=1

print(c)

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

i = 0
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()

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

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

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