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:
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    print(len(S.split('ABC')) - 1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
K=''.join(S.split('ABC'))
print(int((N-len(K))/3))

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 re
n = input()
print(len(re.findall("ABC", input())))

Submission status: Accepted

Solution code:
i = int(input())

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

Submission status: Accepted

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

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, S = open(0).read().split()
N = int(N)

cnt = 0
for i in range(len(S)-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 = 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 = input()
print(input().count("ABC"))

Submission status: Accepted

Solution code:
n = int(input())
txt = input()
num = txt[0:n].count("ABC")
print(num)

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

Submission status: Accepted

Solution code:
N = int(input())
S = str(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:
# -*- coding:utf-8 -*-
n = int(input())
s = input()

print(s.count('ABC'))

Submission status: Accepted

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

def main():
    print(S.count("ABC"))
    return

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 = input()
ans = 0
for i in range(N-2):
    if(S[i:i+3] == 'ABC'):
        ans = 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:
N = int(input())
L = input()
K = 0
for i in range(N-2):
  if L[i] == "A" and L[i+1] =="B" and L[i+2] == "C":
    K = K+1
print(K)

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=input()
S=input() 
cnt=0 
y=S.find("ABC")
if y==-1:
    print(0)
else:
    while y!=-1:
        S=S.replace(S[:y],"",1)
        S=S.replace("ABC","",1) 
        y=S.find("ABC")
        cnt+=1 
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

a = 'ABC'
count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N, s):
    return len(s.split('ABC')) - 1


if __name__ == "__main__":

    N = int(input())
    s = input()
    ans = solv(N, s)

    print(ans)

Submission status: Accepted

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

count = 0
for i in range(len(s)-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()
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())
s = list(input().split("ABC"))
print(len(s)-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
count=0
for i in range(N):
    if (S[i:i+3]=="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 ''.join([s[i],s[i+1],s[i+2]])=='ABC':
    count+=1
print(count)

Submission status: Accepted

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

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:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S=readline().decode('utf8')
print(S.count('ABC'))

Submission status: Accepted

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

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

print(x)

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:
#!/usr/bin/env python3
N = int(input())
S = input()
print(S.count("ABC"))

Submission status: Accepted

Solution code:
import sys
lines = [l.rstrip() for l in sys.stdin.readlines()]
n = int(lines[0])
s = lines[1]

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

print(r)

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(0, n-2):
  if(s[i:i+3] == 'ABC'):
    cnt += 1
  else:
    continue

print(cnt)

Submission status: Accepted

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

while not S.find("ABC") == -1:
    index = S.find("ABC")
    S = S[:index] + S[index+3:]
    count += 1
print(count)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""



n = onem()

a = input()

print(a.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 += 1

print(count)

Submission status: Accepted

Solution code:
# K,X=map(int,input().split())
N = 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 = ans + 1

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(N-2):
    if(S[i:i+3] == 'ABC'):
        ans = 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
from io import StringIO
import unittest

def resolve():
    n=int(input())
    s=input()

    print(s.count("ABC"))

    return

resolve()

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()
count=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:
_ = int(input())
s = str(input())

ans = 0
for i in range(len(s)-2):
    ans += "ABC" == '{}'.format(s[i:i+3])

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

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#main
n=int(input())
s=input()
print(s.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 = int(input())
s = input()
count = 0

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

for i in range(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())
str=input()
k=str.count("ABC",0,n)
print(k)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    S = list(input())
    result = 0
    for i in range(N + 3):
        if S[i:i + 3] == ['A', 'B', 'C']:
            result += 1

    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
s=input()
cnt=0
if len(s)<= 2:
  pass
else:
  for i in range(len(s)-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())
print(input().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:
words = int(input())
text = input()
count = 0
for i in range(len(text) - 2):
  if text[i] == "A" and text[i + 1] == "B" and text[i + 2] == "C":
    count += 1
print(count)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

S = S.replace("ABC", "#")

total = 0
for i in S:
	if i=="#":
		total += 1

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(answer)

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

Solution code:
import re
 
n = int(input())
s = input()
 
abc = re.compile('ABC')
 
count = len(abc.findall(s))
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

mm = ["A","B","C"]
cnt = 0
for i in range(N-2):

    if S[i:i+3] == mm:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
S = str(input())
i = 0
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
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(sum(1 for i in range(N) if S[i:i+3]=="ABC"))

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
row = sys.stdin.readline
def read_int(row):
    return int(row().rstrip())

def read_string(row):
    return row().rstrip()
  
N = read_int(row)
S = read_string(row)

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
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:i+3]=="ABC":
    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
print(count)

Submission status: Accepted

Solution code:
from functools import lru_cache
import sys

sys.setrecursionlimit(10**8)

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

@lru_cache(maxsize=None)
def dp(s):
    result = s.count("ABC")
    return result
print(dp(S))

Submission status: Accepted

Solution code:

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
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()
t=s.split('ABC')
u=''.join(t)
print((n-len(u))//3)

Submission status: Accepted

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

Submission status: Accepted

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

print(s.count('ABC'))

Submission status: Accepted

Solution code:
l = int(input())
i = input()
result = 0

match = ""
for r in range(l):
  if i[r] == "A" and match == "":
    match += i[r]
  elif i[r] == "B" and match == "A":
    match += i[r]
  elif i[r] == "C" and match == "AB":
    match = ""
    result += 1
  else:
    match = i[r]

print(result)

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

Submission status: Accepted

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

print(int(s.count("ABC")))

Submission status: Accepted

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

print(len(S.split('ABC'))-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
cnt = 0
while True:
    a = s.find("ABC")
    if a >= 0:
        s = s[a+3:]
        cnt +=1
    else:
        break
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()
"""
10
ZABCDBABCQ
"""

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

print(num)

Submission status: Accepted

Solution code:
import sys


def solve(inp):
    N = int(inp.readline().strip())
    S = inp.readline().strip()

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

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	S = input()
	S = S[:-1]

	tmp = S.split("ABC")
	ans = len(tmp)

	print(ans-1)


if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

flag = 0
cnt = 0
for i in s:
    if i == "A" and (flag == 0 or flag == 1):
        flag = 1
    
    elif i == "B" and flag == 1:
        flag = 2
    
    elif i == "C" and flag == 2:
        cnt += 1
        flag = 0
    
    else:
        flag = 0

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

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の文字列 Sがあります。
# Sの連続する部分列 (入出力例をご覧ください) として 
# ABC がいくつ含まれるかを求めてください。

# 制約
# 3 ≤ N ≤ 50
# Sは英大文字のみからなる。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S

# 出力
# Sが連続する部分列として含む ABC の個数を出力せよ。

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

input()
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
count = 0
for i in range(N):
	try:
		if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
			count += 1
	except IndexError:
		pass
print(count)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

s = input()

print(s.count('ABC'))

Submission status: Accepted

Solution code:
input()
S=input()
res=0
while S.find('ABC')>-1:
    k=S.find('ABC')
    S=S[:k]+S[k+3:]
    res+=1
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = s.count('ABC')

print(ans)