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()
print(len(S.split('ABC'))-1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def ABC():
    N = wczytaj_liste()[0]
    S = input()
    odp = 0 
    for i in range(N-2):
        if S[i] == 'A':
            if S[i+1] == 'B':
                if S[i+2]=='C':
                    odp += 1
    print(odp)
    
ABC()

Submission status: Accepted

Solution code:
a = int(input())
b = input()
#print(a)
#print(b)

num = b.count('ABC')
print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline()[:-1]

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import re

n = int(input())
s = input()
result = re.findall('ABC', s)
print(len(result))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

# N, Sを入力
n = input()
s = input()

results = re.findall(r"ABC", s)

print(len(results))

Submission status: Accepted

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

S = input()
index = -1
if "ABC" in S:
  S = S.split("ABC")
  print(len(S)-1)
  
  
else:
  print("0")

Submission status: Accepted

Solution code:
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()
print(sum(S[x:x+3]=="ABC" for x in range(N-2)))

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

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    ls = []
    for i in range(N-2):
        if S[i]=="A":
            ls.append(i)

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

if __name__ == '__main__':
    main()

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

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

print(abc_count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

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

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

Submission status: Accepted

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

count=0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
n = int(input())
s = input()
c = 0
for i in re.split('(ABC)',s):
    if i == "ABC":
        c += 1

print(c)

Submission status: Accepted

Solution code:
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())
X = str(input())

print(X.count('ABC'))

Submission status: Accepted

Solution code:
read = input 
rn = lambda :list(map(int, read().split()))
n, = rn()
s = read()
ans = 0
for i in range(n):
    if 'ABC' == s[i:i+3]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = str(input())
S = S.replace("ABC","ab")
print(N - len(S))

Submission status: Accepted

Solution code:
import re

N = input()
S = input()

ls = re.findall(r"ABC", S)

print(len(ls))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
n = int(input())
s = str(input())
print (s.count('ABC'))

Submission status: Accepted

Solution code:
#abc150b

n=int(raw_input())
s=raw_input()
cnt=s.count('ABC')
print cnt

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

"""
name: A-500.py
プログラムの説明
"""

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

    print(S.count('ABC'))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
str = input()

cnt = 0
for i in range(num - 2):
  word = str[i] + str[i+1] + str[i+2]
  if(word == 'ABC'):
    cnt = cnt + 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# K, X = map(int, input().split())
#
# if 500 * K >= X:
#     print('Yes')
# else:
#     print('No')

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

print(S.count('ABC'))

Submission status: Accepted

Solution code:
def solve(n, s):
    return len(s.split("ABC")) - 1

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

Submission status: Accepted

Solution code:
import sys

def main():
	
	#sys.stdin = open('input150b.txt')
	
	n = int(input())
	s = input()
	
	print(s.count('ABC'))
	
if __name__ == '__main__':
	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()
cnt = 0
flag = 0
for i in range(n):
  if s[i] == "A":
    flag = 1
  elif s[i] == "B" and flag == 1:
    flag = 2
  elif s[i] == "C" and flag == 2:
    cnt += 1
    flag = 0
  else:
    flag = 0
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = input()
a = ''
count = 0
for i in l:
  a += i
  if 'ABC' in a:
    a = ''
    count += 1
print(count)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
n = 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())
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())
x=input()
print(x.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
tmp = ""
for elem in s:
  if "A" == elem:
    tmp += elem
  elif "B" == elem and tmp != "":
    if tmp[-1] == "A":
	    tmp += elem
    else:
      	tmp = ""
  elif "C" == elem and tmp != "":
    if tmp[-1] == "B":
    	cnt += 1
    tmp = ""
  else:
    tmp = ""
print(cnt)

Submission status: Accepted

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

import re
print(len(re.findall('ABC', s)))

Submission status: Accepted

Solution code:
import re
n = input()
s = input()
pattern = "ABC"
print(len(re.findall(pattern, s)))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

start = -1
count = 0
while True:
    start = S.find('ABC', start + 1)
    if start != -1:
        count += 1
    else:
        break

print(count)

Submission status: Accepted

Solution code:
N, S = open(0).read().split()
SEARCH_STR = "ABC"
print( S.count( SEARCH_STR ) )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    _, S = [input() for i in range(2)]

    print(S.count('abc') + S.count('ABC'))


if __name__ == "__main__":
    resolve()

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:
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()
count = int(0)
for i in range(len(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()
s += "--"
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:
from sys import stdin
n = int(stdin.readline().rstrip())
s = str(stdin.readline().rstrip())
ans = 0
for i in range(n-2):
    tri = s[i]+s[i+1]+s[i+2]
    if tri == "ABC":
        ans += 1
    else:
        pass

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:
#coding:utf-8
n = int(input())
s = input()
count = 0

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

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

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

ret = 0
n = S.find("ABC")
while n != -1:
    ret += 1
    n = S.find("ABC", n + 1)

print(ret)

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

n = int(sys.stdin.buffer.readline())
s = sys.stdin.buffer.readline().decode().rstrip()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    n=int(input())
    s=input().strip()
    cnt=0
    for i in range(0,n):
            if s[i:i+3]=="ABC":
                cnt+=1
            else:
                pass
    print(cnt)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
print(S.count('ABC'))

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools


def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def mk1d(n, val=INF):
    return [val for i in range(n)]

def mk2d(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]

DIV = 998244353


def convolve(a, b):
    p, g = 1107296257, 5
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)

    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2

    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2

    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


def main():
    N = iRaw()
    S = sRaw()
    ans = S.count("ABC")
    return ans

if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A":
        type = "B"
    elif char == "B" and type == "B":
        type = "C"
    elif char == "C" and type == "C":
        count += 1
        type = "A"
    else:
        type = "A"
print(count)

Submission status: Accepted

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

result=0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
S = str(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:
import re

pattern = r"ABC"

input()  # discard 1 line
string = input()


li = re.findall(pattern, string)

print(len(li))

Submission status: Accepted

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

Submission status: Accepted

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

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:
# coding: utf-8
# Your code here!

from collections import deque

N = int(input())
A = deque(list(input()))
num, tmp, ans = 0, 0, 0

for i in range(len(A)):
    tmp = A.popleft()
    if num == 0 and tmp == 'A':
        num = 1
    elif num == 1 and tmp == 'B':
        num = 2
    elif num == 1 and tmp == 'A':
        pass
    elif num == 2 and tmp == 'C':
        num = 0
        ans += 1
    else:
        num = 0
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = input()
    print(s.count('ABC'))
        
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

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()
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:
# coding: utf-8
n = int(input())
s = input()
print(s.count('ABC'))

Submission status: Accepted

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

cnt = 0
for i in range(n - 2):
    num = 1
    if s[i] != "A":
        num = 0
    if s[i + 1] != "B":
        num = 0
    if s[i + 2] != "C":
        num = 0    
    cnt += num

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

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 n in range(N-2):
  if (S[n]=="A") and (S[n+1]=="B") and (S[n+2]=="C"):
    cnt = cnt+1
print(cnt)

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
    else:
        continue
      
print(ans)

Submission status: Accepted

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

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

print(Ss.count('ABC'))

Submission status: Accepted

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

print(lst.count("ABC"))

Submission status: Accepted

Solution code:
N = int(input())
S = str(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:
def check_substring(s,i):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    return True
  else:
    return False
no = 0
n = int(input())
s = input()
for i in range(n-2):
  if check_substring(s,i)==True:
    no+=1
print(no)

Submission status: Accepted

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

import string
print(S.count("ABC"))

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 = str(input())
abc = []
for i in range(N-2):
  if S[i] == 'A':
    if (S[i+1] =='B') and (S[i+2] == 'C'):
      abc.append(i)
ans = len(abc)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(s.count('ABC'))

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input())
S = input()
print(S.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

N = int(readline())
S = list(map(lambda x: ord(x)-65, readline().strip()))

ans = 0
for i in range(N-2):
    for j in range(3):
        if S[i+j] != j:
            break
    else:
        ans += 1
print(ans)

Submission status: Accepted

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

start = 0
ans = 0
while True:
    start = s.find('ABC', start)
    if start < 0:
        break
    ans += 1
    start += len('ABC')
print(ans)

Submission status: Accepted

Solution code:
import re


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

regex = re.compile(r'ABC')
res = regex.findall(S)

print(len(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    S=input()

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

    print(ans)
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n, s = sys.stdin.read().split()
n = int(n)

def main():
    return s.count('ABC')

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

a = s.count('ABC')

print(a)

Submission status: Accepted

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

result = text.count("ABC")

print(result)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
x = [input() for _ in range(2)]
ans = 0
for i in range(len(x[1])-2):
    if x[1][i] == 'A' and x[1][i+1] == 'B' and x[1][i+2] == 'C':
        ans += 1
print(ans)

Submission status: Accepted

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

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

p = 0
c = 0
for i in range(N):
    if S[i] == 'A':
        p = 1
    elif p == 1 and S[i] == 'B':
        p = 2
    elif p == 2 and S[i] == 'C':
        c += 1
        p = 0
    else:
        p = 0

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

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

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()
ABC = 'ABC'

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

Submission status: Accepted

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

count = 0

while True:
    index_ABC = S.find('ABC')
    if index_ABC != -1:
        S = S[:index_ABC] + S[index_ABC + 3:]
        count += 1
    else:
        break

print(count)

Submission status: Accepted

Solution code:
_,s=open(0);print(s.count('ABC'))

Submission status: Accepted

Solution code:
print(open(0).read().count('ABC'))

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:
import re

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

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

Submission status: Accepted

Solution code:
n, s = int(input()), input()
print(s.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
    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()
c=s.count("ABC")
print(c)

Submission status: Accepted

Solution code:
_,s=open(0);print(s.count("ABC"))

Submission status: Accepted

Solution code:
def count(s, idx):
	ac = 0
	step = 0
	bc = 0
	cc = 0
	c = 0
	while(idx < len(s) and step < 3):
		if s[idx] == 'A' and bc == 0 and cc == 0:
			ac = 1
		elif s[idx] == 'B' and cc == 0 and ac == 1:
			bc = 1
		elif s[idx] == 'C' and bc == 1 and ac == 1:
			cc = 1
		idx += 1
		step += 1
	c = ac + bc + cc
	if c == 3:
		return 1
	return 0

n = int(input())
s = input()
summ = 0
for i in range(n):
	if s[i] == 'A':
		if count(s, i) == 1:
			summ += 1
print(summ)