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



Sample input:
10
ZABCDBABCQ


Sample output:
2

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
lens = int(input())
has  = input()
print(has.count("ABC"))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
l = 'ABC'
count = 0

for i in range(n-2):
    if s[i: i+3] == l:
        count += 1
        
        
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
S = input()
array_S = list(S)

if not ( 3 <= N <= 50 and S.isupper() ): sys.exit()

count = 0
for I in range(N-2):
    if ''.join(array_S[I:I+3]) == 'ABC':
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = input()
S = input()
newS = S.replace("ABC", "")
print((len(S) - len(newS)) // 3)

Submission status: Accepted

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

print(S.count('ABC'))

Submission status: Accepted

Solution code:
"""
全探索
先頭から3文字ずつで切っていき、"ABC"か判定し、区切りを1個後ろへずらす
"""
n = int(input())
s = input()
ans = 0
for i in range(len(s)-2) :
    if s[i:i+3] == "ABC" :
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input().split("ABC")
print(len(S)-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
ans=0
for x in range(N-2):
  if S[x]=='A':
    if S[x+1]=='B':
      if S[x+2]=='C':
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
print(len([i for i in range(N-2) if S[i:i+3]=='ABC']))

Submission status: Accepted

Solution code:
def abc_150b():
    n = input()
    s = input()
    cnt = 0

    # python的にはstrに関数が準備されているので、それでもOK
    cnt = s.count('ABC')

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

    print(cnt)

if __name__ == '__main__':
    abc_150b()

Submission status: Accepted

Solution code:
def abc_150b():
    n = input()
    s = input()
    cnt = 0

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

    print(cnt)

if __name__ == '__main__':
    abc_150b()

Submission status: Accepted

Solution code:
######################
#     _        ____  #
# U  /"\  u U /"___| #
#  \/ _ \/  \| | u   #
#  / ___ \   | |/__  #
# /_/   \_\   \____| #
#  \\    >>  _// \\  #
# (__)  (__)(__)(__) #
# Compro by NULL_CT© #
######################
from sys import stdin
import numpy as np
import math

input = stdin.readline

def divisor(_n):
    result = []
    for i in range(1, int(math.sqrt(_n)) + 1):
        if _n % i == 0:
            result.append(i)
            if _n % (_n / i) == 0:
                result.append(int(_n / i))
    return result

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = s()

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

print(cnt)

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = s()
print(s.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
s2 = s.replace("ABC","")
print(int((len(s)-len(s2))/3))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def countABC(n, s):

    return s.count("ABC")

def main():
    n = int(input())
    s = str(input())
    print(countABC(n, s))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(S.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=list(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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
input = stdin.readline

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

print(S.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
count = 0
if N == 3:
  if S == 'ABC':
    count = 1
elif N > 3:
	for i in range(N-2):
		if S[i] == 'A':
			if S[i+1] == 'B':
				if S[i+2] == 'C':
					count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    S = str(input())
    ans = 0

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


resolve()

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    S = str(input())
    print(S.count('ABC'))
    return
resolve()

Submission status: Accepted

Solution code:
N=input()
N=int(N)
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)

Submission status: Accepted

Solution code:
def main():
  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)
main()

Submission status: Accepted

Solution code:
input();print(input().count("ABC"))

Submission status: Accepted

Solution code:
_ = input()
s = input()
x = s.count('ABC')
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

print((input() + input()).count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
N=int(input())
S=input()
result=re.findall(r'(ABC)', S)
print(len(result))

Submission status: Accepted

Solution code:
input()
S = input()
count = 0
for i in range(0, len(S)):
    if S[i:i+3] == "ABC" : count = count + 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  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)
  
  
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = str(input())
c = b.count("ABC")
print(c)

Submission status: Accepted

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

n = n-2
count = 0
for i in range(n):

    if s[i]+s[i+1]+s[i+2] == "ABC":
        count = count+1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(S.count("ABC"))

Submission status: Accepted

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

print(s.count("ABC"))

Submission status: Accepted

Solution code:
input()
S = input()

print(S.count('ABC'))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
l = [S[i:i+3] for i in range(0, len(S)-2)]
print(l.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
_ = input()
S = input()

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    total = 0
    for i in range(len(S) - 2):
        if S[i] + S[i + 1] + S[i + 2] == 'ABC':
            total += 1  
    print(total)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
target = "ABC"
j = 0
count = 0
for i in range(N):
    if S[i] == target[0]:
        j = 0
    if S[i] == target[j]:
        j += 1
    else:
        j = 0
    if j == 3:
        count += 1
        j = 0
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
while len(s) > 2:
    if s[0] == "A" and s[1] =="B" and s[2] == "C":
        count += 1
        del s[0:2]
    else:
        del s[0]

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

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

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S=list(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)

Submission status: Accepted

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


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

print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
count = 0
if n % 3 == 1 or n % 3 == 0:
  for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
      count += 1
elif n % 3 == 2:
  for i in range(n-2):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
      count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
a = 0
if n % 3 == 1 or n % 3 == 0:
  for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
      a += 1
elif n % 3 == 2:
  for i in range(n-2):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
      a += 1
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
	count = 0
	num = int(input())
	strings = input()
	
	for i in range(0,num-2,1):
		if strings[i] == "A" and strings[i+1] == "B" and strings[i+2] == "C":	
			count += 1
	print(count)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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


def main():
    N = int(readline())
    S = readline().strip()
    
    print(S.count('ABC'))
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

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


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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

S = input()

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
cnt = 0

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

Submission status: Accepted

Solution code:
_=input();print(input().count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

flag =0

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

print(flag)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
s = input()
print(sum(s[i:i + 3] == "ABC" for i in range(n - 2)))

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
cnt = 0

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
str="ABC"
c=0
i=2
while i<=N-1:
    if S[i] == "C":
        if S[i-1]=="B":
            if S[i-2]=="A":
                c+=1
                i+=3
            else:
                i+=3
        else:
            i+=3
    else:
        i+=1
print(c)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
counter = 0
for i in range(n):
  j = i +3
  if j > n:
    break
  if s[i:j] == 'ABC':
    counter += 1
print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
string = input()

count = 0

for i in range(len(string)):
	if string[i] == 'A':
		if i < len(string)-2 and string[i+1] == 'B':
			if string[i+2] == 'C':
				count += 1


print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input().replace('ABC','1')
print(s.count('1'))

Submission status: Accepted

Solution code:
N=int(input())
S=input()
print(sum(S[i]=='A' and S[i+1]=='B' and S[i+2]=='C' for i in range(N-2)))

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())
S = list(str(input()))

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
count=0
for i in range(N):
  if S[i]=='A':
    if S[i+1:i+3]=='BC':
      count+=1
print(count)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
t="ABC"

print(s.count(t))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
idx = 0
res = 0
while idx + 2 < N:
    if S[idx] == 'A':
        if S[idx:idx+3] == 'ABC':
            res += 1 
            idx += 3
            continue
    idx += 1
print(res)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = s.count('ABC')

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
cs = list(s)

ss = []
for i in range(len(cs)-2):
  ss.append(cs[i]+cs[i+1]+cs[i+2])

count = 0
for i in ss:
  if i == "ABC":
    count += 1
  
print(count)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
import sys    #インタプリタや実行環境に関する情報を扱うためのライブラリ
import os     #フォルダやファイルを操作
import math

#標準入力
n = int(input())
#inputはstr(string)で入力されるのでstrの場合は指定不要
S=input()
#inputが改行されている場合は別途入力でよい



print(S.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n,s):
  cnt = 0
  for i in range(len(s)-2):
    if "A" == s[i] and "B" == s[i+1] and "C" == s[i+2]:
      cnt+=1
  return cnt
 
n = int(input())
s = input()
ans = solve(n,s)
print(ans)

Submission status: Accepted

Solution code:
def solve(n,s):
  cnt = 0
  for i in range(len(s)-2):
    if "ABC" == s[i:i+3]:
      cnt+=1
  return cnt
 
n = int(input())
s = input()
ans = solve(n,s)
print(ans)

Submission status: Accepted

Solution code:
def solve(n,s):
  if "ABC" not in s:
    return 0
  cnt = 0
  for i in range(len(s)-2):
    if "ABC" == s[i:i+3]:
      cnt+=1
  return cnt

n = int(input())
s = input()
ans = solve(n,s)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
s1= input()

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

print(count)

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

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

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

Submission status: Accepted

Solution code:
N = int(input())

S = input()

print(S.count("ABC"))

Submission status: Accepted

Solution code:
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
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = LS2()

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 140 B

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

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

print(num)

Submission status: Accepted

Solution code:
N = int(input())
Ss = input().rstrip()

ans = Ss.count('ABC')
print(ans)

Submission status: Accepted

Solution code:
A=int(input())
N=input()
ans=N.count("ABC")
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
arr=input()
print(arr.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def have_ABC_string(n, str):
    count = 0
    for i in range(n-2):
        if str[i] == 'A' and str[i+1] == 'B' and str[i+2] == 'C':
            count += 1
    return count

N = int(input())
S = input()
result = have_ABC_string(N, S)
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
s = input()
 
count = 0
 
for i in range(len(s)):
  if s[i:i+3]=='ABC':
    count += 1
print(count)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
c=0

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# count()を使わないで解く
r = 0
for i in range(n-2):
  if s[i:i+3] == "ABC":
    r += 1
print(r)