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

result=0

for index, sss in enumerate(S):
    if S[index:index+3]=="ABC":
        result+=1

print(result)

Submission status: Accepted

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

result = 0

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

print(result)

Submission status: Accepted

Solution code:
_ = int(input())
s = input()
import re
print(len(re.findall(r'ABC', s)))

Submission status: Accepted

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

print(len([0 for c1, c2, c3 in zip(S, S[1:], S[2:]) if c1 == 'A' and c2 == 'B' and c3 == 'C']))

Submission status: Accepted

Solution code:
# B - Count ABC
# https://atcoder.jp/contests/abc150/tasks/abc150_b

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

Submission status: Accepted

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

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

print(num)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes,no): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
n=n0()
s=s0()
print(s.count("ABC"))

Submission status: Accepted

Solution code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

n = int(input())
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

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

print(flag)

Submission status: Accepted

Solution code:
import re

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
S=list(ns())
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())
w = input()

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

Submission status: Accepted

Solution code:
_ = int(input()) #文字数だが不使用のためアンダースコアで受ける
S = input()

print(S.count("ABC"))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
result=''
count=0 
for i in s:
    result+=i
    if result.endswith('ABC'):
        count+=1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#python 3.7

a=int(input())

p=str(input())

  

print(p.count("ABC"))

Submission status: Accepted

Solution code:
n=int(input())
s=str(input())
#s=list(s)
count=0
i=0
ans=s.count("ABC")
  
print(ans)

Submission status: Accepted

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

print(S.count('ABC'))

Submission status: Accepted

Solution code:
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
s=input()
print(s.count("ABC"))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, S = open(0).read().rstrip().split('\n')
ans = 0
for i in range(int(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(0, n-2):
    if 'ABC' == s[i:i+3]:
        ans += 1
print(ans)

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


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

print(a)

Submission status: Accepted

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

Submission status: Accepted

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

print(s.replace("ABC", "x").count("x"))

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

Submission status: Accepted

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

s = list(s)
count = 0
if n >= 3:
    for i in range(n-2):
        if s[i] == 'A':
            if s[i + 1] == 'B' and s[i + 2] == 'C':
                count += 1
print(count)

Submission status: Accepted

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

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

def main():

    steps=0
    state=0
    w=1
    j=0
    k=0
    n=int(input())
    s=input()
    ans=0
    a=[i for i in s]#int取るとstrでも行ける
    for i in range(len(s)-2):
        '''
        sを切り抜くやり方で可能だが今回はacを優先
        '''
        if a[i]=="A" and a[i+1]=="B" and a[i+2]=="C":
            ans +=1
    print(ans)
    #a,b=map(int, input().split(" "))
    #nl=list(map(int, input().split(" ")))#数字の時




    #if state in known_states and not flag: # state => 2 steps => 5
        #こうやってある要素がリストの中にあるか探すのか
    #print(f'steps: {steps}, state: {state}')
    #こう書いてあるとデバックしやすい

    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)


    "1行1つの整数を入力を取得し、整数と取得する"
    #nl=list(map(int, input().split(" ")))#数字の時
    #print(number_list)
    "12 21 332 とか入力する時に使う"
    "1行に複数の整数の入力を取得し、整数として扱う"
    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)


    #s=input()
    #a=[int(i) for i in s]#int取るとstrでも行ける
    #print(a)
    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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=count+1
                i=i+3
            else:
                i=i+2
        else:
            i=i+1
print(count)

Submission status: Accepted

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

# check
cnt = 0
for i in [ind for ind, s in enumerate(S) if s == "A" and len(S[ind:]) >= 3]:
    if S[i:i + 3] == "ABC":
        cnt += 1

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
import bisect


def main():
    n = int(input())
    s = input()
    ans = 0
    for i in range(n):
        if i + 3 <= n:
            if s[i:i+3] == 'ABC':
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

s = s.replace("ABC","")

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    s = list(input()[:-1])
    abc = list('ABC'.encode())
    ans = 0
    for i in range(n - 2):
        if s[i: i + 3] == abc:
            ans += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

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

total = 0
for i in range(3, len(S) + 1):
    total += int(S[i-3:i] == 'ABC')

print(total)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    S = list(input().rsplit()[0])

    ans = 0
    for i in range(len(S)):
        s = "".join(S[i:i+3])
        if s == 'ABC':
            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:
N=int(input())
S=list(input())

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

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

nums = s.count('ABC')

print(nums)

Submission status: Accepted

Solution code:
# exec(open('test.py').read()) 
 
N = int(input())
S = input()

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

S = input()

print(S.count('ABC'))

Submission status: Accepted

Solution code:
import fileinput

n = input()
s = input()

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

Submission status: Accepted

Solution code:
n = input()

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

print(ans)

Submission status: Accepted

Solution code:
n1 = int(input())
s2 = input()

c3 = s2.count("ABC")

print(c3)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 14:21:04 2020

@author: shinba
"""

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

print(s.count("ABC"))

Submission status: Accepted

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

def counter(s,ans=0):
  if len(s) <= 2:
    return ans
  elif s[:3] == "ABC":
    return counter(s[1:],ans+1)
  else:
    return counter(s[1:],ans)

print(counter(S))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans =0
for i in range(n):
  if s[i]=="A":
    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(len(S)):
    if S[i:i+3] == 'ABC':
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    for j in range(i+1, n+1):
        if s[i:j] == '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())
str = input()
count = 0

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

print(count)

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

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

Submission status: Accepted

Solution code:
N = int(input())
S_str = input()
counter = 0
for i in range(N):
    if S_str[i:i+3].startswith('ABC'):
        counter += 1
print(counter)

Submission status: Accepted

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

cnt = 0
while 1:
    idx = S.find('ABC')
    if idx==-1:
        break
    else:
        cnt += 1
        S = S[idx+3:]

print(cnt)

Submission status: Accepted

Solution code:
import sys

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:
if __name__ == "__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)

Submission status: Accepted

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

#n = 10
#s = 'ZABCDBABCQ'

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 0

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

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

print(ans)

Submission status: Accepted

Solution code:

N = input()
S = input()

print(S.count("ABC"))

Submission status: Accepted

Solution code:
# B - Count ABC

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def num_of_ABC(str):
    number = str.count("ABC")
    return number

if __name__ == "__main__":
    _ = input()
    sentence = input()
    num = num_of_ABC(sentence)
    print(num)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
count=0
i=0
while i<=n-3:
    if s[i]=="A":
        if s[i+1]=="B" and s[i+2]=="C":
            count+=1
            i+=3
        else: i+=1
    else: i+=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=count+1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = [i for i in input()]
count = 0
total = 0
for p in s:
  if p == "A":
    count = 1
  elif count == 1 and p == "B":
    count = 2
  elif count == 2 and p == "C":
    count = 0
    total += 1
  else:
    count = 0
print(total)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

import re

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = input()
    r = 0
    for i1 in range(0,n-2):
        r += s[i1:i1+3] == 'ABC'
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

s = input()
sx = s.split("ABC")

print(len(sx)-1)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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())
S = input()
S += 'a'
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: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):
  subs = S[i:i+3]

  if(subs == "ABC"):
    ans += 1


print(ans)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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