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()
x=[str(c) for c in s]
count=0
for i in range(n-2):
  if x[i]=="A" and x[i+1]=="B" and x[i+2]=="C":
    count+=1
print(str(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, groupby
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

print(count)

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


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

    N = ii()
    S = iss()
    ret = 0
    print(sum((S[n:n+3] == 'ABC') for n in range(N-2)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, S: str):
    c=0
    for i in range(N-2):
        if S[i]=='A':
            if S[i+1]=='B':
                if S[i+2]=='C':
                    c+=1
    print(c)
    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()

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

Submission status: Accepted

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

#ABC150-B
if True:
    N=int(input())
    S=input()
    print(S.count('ABC'))

Submission status: Accepted

Solution code:
import math

n = int(input())

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

i = s.find('ABC',0)
while i >= 0:
    i = s.find('ABC',i + 3)
    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] + s[i + 1] + s[i + 2] == 'ABC':
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    print(s.count("ABC"))


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

print(res)

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]+s[i+2] == "BC":
      count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

match_word = 'ABC'
bool_count = 0
for i in range(0, N - 2):
    if ''.join(string_data[i:i+3]) == match_word:
        bool_count += 1

print(bool_count)

Submission status: Accepted

Solution code:
result = int(input())
moji = str(input())
print(moji.count("ABC"))

Submission status: Accepted

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

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

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 = count + 1
print(count)

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


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

    N = ii()
    S = iss()
    print(S.count('ABC'))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(len(list(re.finditer('ABC',S))))

Submission status: Accepted

Solution code:
l=int(input())
s=input()
# s=s.replace("ABC","0")
# print(s)
print(s.count("ABC"))

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

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

cnt = 0
for i in range(n):
    if i > n-3:
        break
    a_str = s[i] + s[i+1] + s[i+2]
    if a_str == 'ABC':
        cnt += 1


print(cnt)

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()
index=0
ans=0
while 1:
  if s.find('ABC',index)!=-1:
    index=s.find('ABC',index)+1
    ans+=1
  else:
    break
    
print(ans)

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

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

Submission status: Accepted

Solution code:
a=input()
a=input()

print(len(a.split("ABC"))-1)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

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

print(ans)

Submission status: Accepted

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

print(sum([int(bool(S[i:i+3]=='ABC')) for i in range(0,N-2)]))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(map(str, input()))
# print(S)
count = 0
for i in range(N - 2):
    cha = "".join(S[i:i + 3])
    # print(cha)
    if cha == "ABC":
        count += 1
    else:
        continue

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

#パクリ
#print(S.split("ABC"))
print(len(S.split("ABC")) - 1)

Submission status: Accepted

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

k = 0

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

Submission status: Accepted

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

# Sに'ABC'がいくつ含まれているか

count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
s = input()
print(s.count("ABC"))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s = str(readline())
answer = s.count('ABC')
print(answer)

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

Submission status: Accepted

Solution code:
N = input()

print(input().count("ABC"))

Submission status: Accepted

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

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

print(i)

Submission status: Accepted

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

count = S.count('ABC')

print(count)

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


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

    N = ii()
    S = iss()
    print(sum(S[n:n+3] == 'ABC' for n in range(N-2)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
count = 0
c = "ABC"
for i in range(n-2):
	if s[i:i+3] == 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:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    s=STR()
    ct=0
    for i in range(n-2):
        if s[i:i+3]=='ABC':
            ct+=1
    print(ct)
            
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
a = int(input())
b = input()
count=0
for i in range(len(b)):
    if b[i:i+3] == 'ABC':
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n = int(input())
  s = input()
  
  cnt = 0
  for i in range(1,n-1):
    if s[i] == 'B':
      if s[i-1] == 'A' and s[i+1] == 'C':
        cnt += 1
  print(cnt)
if __name__ == '__main__':
  main()

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from fractions import gcd                    # for Python3.4.3


def main():
    mod = 10000007                  # 10^9+7
    inf = float('inf')
    input = sys.stdin.readline      # 改行文字が残ることに注意
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    
    n = ii()
    s = input()
    ans = 0
    for i in range(n):
        if i+2 <= n-1 and s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
            ans += 1
    print(ans)
    

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# 初期入力
N =int(input())
S = input()
"""
ABC_count = 0
for i in range(N-3):
    if S[i:i+3] =="ABC":
        ABC_count += 1
    
print(ABC_count)
"""
a=S.count("ABC")

print(a)

Submission status: Accepted

Solution code:
N=int(input())
s=list(map(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().rstrip()

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()
count =0
flg = 0
for s in S:
    if s == "A":
        flg = 1
    elif s == "B" and flg == 1:
        flg =2
    elif s =="C" and flg ==2 :
        count +=1
        flg =0
    else:
        flg = 0
print(count)

Submission status: Accepted

Solution code:
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/B-CountABC.py
#
N = int(input())
S = str(input())

print(S.count("ABC"))

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
w = "ABC"
ans = 0
for i in range(n-2):
    if s[i:i+3] == w:
        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:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = sr()
answer = S.count('ABC')
print(answer)

Submission status: Accepted

Solution code:
N,S=open(0);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(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:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = sr()
answer = 0
for x, y, z in zip(S, S[1:], S[2:]):
    if x + y + z == 'ABC':
        answer += 1
print(answer)
# 36

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=str(input())
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 = str(input())
cnt = 0
if N <= 2:
    print(0)
else:
    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 = list(input())

ans = 0
for i in range(n):
    ss = s[i:i+3]
    if ss== ["A","B","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:
N = int(input())
S = input().upper()
ans = S.count('ABC')
print(ans)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

cnt = 0
for i in range(0, 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()
i=0
res=0
while i>=0:
  i=s.find("ABC")
  if i >= 0:
    res += 1
    s=s[i+3:]
print(res)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
s=list(input())
tmp1 = s[0]
tmp2 = s[1]
tmp3 = s[2]
c = 0
if tmp1+tmp2+tmp3 == 'ABC':
        c += 1
for i in range(len(s)-3):
    tmp1 = tmp2
    tmp2 = tmp3
    tmp3 = s[i+3]
    if tmp1+tmp2+tmp3 == 'ABC':
        c += 1
    else:
        continue
print(c)

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    length = int(input())
    sentence = input()

    counter = 0
    for i in range(length - 2):
        if sentence[i:i+3] == 'ABC':
            counter += 1

    print(counter)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# Problem - Count ABC

# input
N = int(input())
S = list(input())

# initialization
abc_count = 0

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

# output
print(abc_count)

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


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

Submission status: Accepted

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

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

print(x)

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)