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: Wrong Answer

Solution code:
n = int(input())
s = list(input())
tmp = "A"
ans = 0

for i in range(n):
    if s[i] == tmp:
        if tmp == "A":
            tmp = "B"

        elif tmp == "B":
            tmp = "C"

        elif tmp == "C":
            tmp = "A"
            ans += 1

    else:
        tmp = "A"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys; readline = sys.stdin.readline
from collections import deque

N = int(readline())
S = readline().rstrip()

count = 0

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

print(count)

Submission status: Wrong Answer

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

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

print(answer)

Submission status: Wrong Answer

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

print(res)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag = 0
ans = 0
for i in range(N):
    if flag == 0:
        if S[i] == "A":
            flag+=1
    elif flag == 1:
        if S[i] == "B":
            flag+=1
        else:
            flag = 0
    elif flag == 2:
        if S[i] == "C":
            ans+=1
        flag = 0

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = 0
for i in s:
  if i == "ABS":
    ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a = int(input())
    s = input()
    count = 0
    check = 0
    for i in s:
        if check == 0 and i == "A":
            check = 1
        elif check == 1 and i == "B":
            check = 2
        elif check == 2 and i == "C":
            count = count +1
            check = 0
        else:
            check =0

    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
i = 0
while i < n - 3:
    if s[i:i + 3] == 'ABC':
        ans += 1
        i += 3
    else:
        i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

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

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input().strip()
ANS=0

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

print(ANS)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
#N,K = list(map(int,input().split()))
#s = [int(input()) for i in range(3)]
S = input()
count = 0
for i in range(N-3):
    if S[i:i+3] == 'ABC':
        count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = 0
s = 0
for k in S:
    if s == 0 and k == "A":
        s = 1
    elif s == 1 and k == "B":
        s = 2
    elif s == 2 and k == "C":
        c += 1
        s = 0
    else:
        s = 0
print(c)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n = int(readline())
s = readline().decode("utf-8")

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, S: str):
    count = 0
    for i in range(N-3):
        if S[i:i+3] == "ABC":
            count += 1
    print(count)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
i = 0
cnt = 0
while i <= n -3:
  if s[i:i+3] == 'ABC':
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
input()
s = input()
i = s.find('ABC')
n = 0
while i != -1:
  i = s.find('ABC'[i+3:])
print(n)

Submission status: Time Limit Exceeded

Solution code:
s = [input() for i in range(2)]
a = [str(c) for c in s[1]]
x = 0
ans = 0

while x + 3 <= len(s[1]):
  if str(str(a[x]) + str(a[x + 1]) + str(a[x + 2])) == 'ABC':
    ans = ans + 1
  else:
    pass
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = input()
i = 0
ans = 0
while i < n:
  if s[i] == 'A' and s[i:i+3] == 'ABC':
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
for i,s in enumerate(S):
  if s == 'A' and S[i:i+3] == 'ABC':
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(s.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

print(text.count('ABC'))

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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())
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 = list(input())
ans = 0
for i in range(len(S)-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 = list(input())
count=0
for i in range(n-2):
    if s[i] == "A":
        if s[i+1] == "B":
            if s[i+2] == "C":
                count+=1
print(count)

Submission status: Accepted

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

print(s.count("ABC"))

Submission status: Accepted

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

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(0, N-2):
	if S[i:i+3] == 'ABC':
		cnt += 1

print(cnt)

Submission status: Accepted

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

l=list(s.split("ABC"))
r=len(l)-1
if r==-1:
    r=0
print(r)

Submission status: Accepted

Solution code:
n = int(input())

s = input()

print(s.count("ABC"))

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
# 2020/09/18
# AtCoder Beginner Contest 150 - B

# Input
n = int(input())
s = input()
cnt = 0
abc = 'ABC'

# Calc
for i in range(n-2):
    for j in range(3):
        if s[i+j] != abc[j]:
            break
        if j == 2:
            cnt = cnt + 1

# Output
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np

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

""" 3文字ずつスライスし判定
S = input()
count = 0
# スライスでi+2文字目まで行くのでfor文範囲はN-2でとどめる
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()

print(s.count('ABC'))

Submission status: Accepted

Solution code:
import re
n = int(input())
s = input()
a = []
ans = 0
for i in range(n):
    if s[i] == 'A':
        a.append(i)
for i in a:
    if s[i:i+3] == 'ABC':
        ans += 1
print(ans)

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

n = int(input())
text = input()

pattern = "ABC"
result = re.findall(pattern, text)
print(len(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()
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()

print(S.count('ABC'))

Submission status: Accepted

Solution code:
N = input()
straw = input()
straw = straw.split('ABC')
print(len(straw) - 1)

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 s[i : i + 3] == "ABC":
        count += 1


print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
n = input()
t = "ABC"
c = 0;
for i in range(x-2):
	if n[i] == 'A' and n[i+1] =='B' and n[i+2] == 'C':
		c+=1
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(text.count("ABC"))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
i = 0
cnt = 0
while i < n:
  if s[i:i+3] == 'ABC':
    cnt += 1
    i += 3
  else:
    i += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

print( ABC_count )

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
temp=""
ans=0
for i in range(N):
	if S[i]=="A":
		temp="A"
	elif S[i]=="B" and temp=="A":
		temp="B"	
	elif S[i]=="C" and temp=="B":
		temp=""
		ans+=1
	else:
		temp=""

print(ans)

Submission status: Accepted

Solution code:
t = input()
al = input()
count = 0
for i in range(len(al)):
  if al[i:].startswith('ABC'):
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 任意のi(0≤i≤n-3)について、S[i]以下3文字が'ABC'であるかを確認すればよい
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())
abc_cnt = 0
cnt = 0
i = 0

while(i < n - 2):
    if(s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'):
        cnt += 1
        if i < n -3:
            i = i+3
        else:
            i += 1
    else:
        i += 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 = S.count("ABC")
print(ans)

Submission status: Accepted

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

cnt=0

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

print(cnt)

Submission status: Accepted

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

count = word.count("ABC")
print(count)

Submission status: Accepted

Solution code:
l=int(input())
n=input()
ans=0
for i in range(len(n)-2):
    if n[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:
n = int(input())
s = input()

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

Submission status: Accepted

Solution code:

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
S = input()
if not "ABC" in S:
  print(0)
  exit()
else:
  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] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'):
        ans = ans + 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(len(s)-2):
    if "ABC" == s[i:i+3]:
        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()
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()
m = len(s.replace("ABC", ""))
print((n - m) // 3)

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

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

Submission status: Accepted

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


cn = 0

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

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

Submission status: Accepted

Solution code:
# 各桁の数値の総和を計算する.
def calc_digit_sum(num):
    sums = 0
    while num > 0:
        sums += num % 10
        num //= 10
    return sums


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

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

Submission status: Accepted

Solution code:
input()
s = input()
l = len(s)
s2 = s.replace('ABC', '')
 
l2 = len(s2)
 
print((l-l2) // 3)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(S.count("ABC"))

Submission status: Accepted

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

print(s.count("ABC"))

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
s=list(input())
ans=["A","B","C"]
count=0
for i in range(n-2):
    cnt=0
    for j in range(len(ans)):
        if s[i+j]==ans[j]:
            cnt+=1
    if cnt ==3:
        count+=1
print(count)

Submission status: Accepted

Solution code:
N=int(input())
S=str(input())
S=list(map(str,S))
count=0
for i in range(N-2):
  if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C':
    count+=1
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()
 
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:
import sys
import re


def resolve(in_):
    N = int(next(in_))
    S = next(in_).strip()

    answer = sum(1 for _ in re.finditer('ABC', S))
    return answer


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

abc = "ABC"
ans = 0
j = 0

for i in range(N):
    if S[i] == abc[j]:
        j += 1
        if S[i] == "C":
            j = 0
            ans += 1
    elif S[i] == "A":
        j = 1
    else:
        j = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc150/tasks/abc150_b
N= int(input())
s= input()

A= []
A= list(s)

#print(A)

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

print(add)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
#print(n , s , ' ')
p = "ABC"
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    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(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:
import re
N = input()
S = input()
print(len(re.findall('.?ABC', S)))

Submission status: Accepted

Solution code:
N=int(input())
S=input()
a='ABC'
x=0
y=0
for  i in range(N-2):
    x=0
    for j in range(3):
        if S[i+j]==a[j]:
            x+=1
        else:
            break
    if x==3:
        y+=1
print(y)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

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


def main():
    solve()


if __name__ == '__main__':
    main()

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):
    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] +S[i+1] + S[i+2] == 'ABC':
        count +=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    cnt=0
    for i in range(N-2):
        if s[i:i+3]=="ABC":
            cnt+=1
    print(cnt)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

main()

Submission status: Accepted

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