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

Submission status: Accepted

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

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

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

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:
def main():
    _ = int(input())
    s = input()
    cnt = 0
    for i in range(len(s) - 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()
count = 0
for i in range(n-2):
  if s[i:i+3] == "ABC":
    count += 1
print(count)

Submission status: Accepted

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

    print(cnt)

if __name__ == "__main__":
    main()

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

s1 = s.replace('ABC','1')
print(s1.count('1'))

Submission status: Accepted

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

def dfs(s):
    if len(s) < 2:
        return 0
    elif s[:3] == 'ABC':
        return 1 + dfs(s[3:])
    else:
        return dfs(s[1:])

print(dfs(s))

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N = i_i()
S = i_s()

print(S.count('ABC'))

Submission status: Accepted

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

import sys


def input():
    return sys.stdin.readline()


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

    abc_count = s.count("ABC")

    print(abc_count)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

def solve():
    N = int(input())
    S = input()
    spl = S.split("ABC")
    print(len(spl)-1)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
#n,m=map(int,input().split())
#pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

sl=list(input())

org=["A","B","C"]
ans=0
for i in range(n-2):
    templ=sl[i:i+3]
    if templ==org :
        ans+=1
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

c = s.count("ABC")
print(c)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    ct = 0
    for i in range(N-2):
        p = S[i:i+3]
        if p == 'ABC':
            ct += 1

    print(ct)
    

main()

Submission status: Accepted

Solution code:
from sys import stdin

lines = stdin.readlines()

n = int(lines[0].rstrip())
s = str(lines[1].rstrip())

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

N = input()
S = input()
m = re.findall(r"ABC", S)

print(len(m))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = int(input())
s = input()

print(s.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

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

s = S.replace('ABC', ',').split(',')

print(len(s) - 1)

Submission status: Accepted

Solution code:
import sys
import re
from decimal import *

l = sys.stdin.readline()
l = sys.stdin.readline()
#l = l.split(' ')
#l = [int(str) for str in l]
s = l

state = 0
count = 0
for i in s:
  if(i == 'A'):
    state = 1
  else:
    if(i == 'B' and state == 1):
      state = 2
    else:
      if(i == 'C' and state == 2):
        state = 0
        count += 1
      else:
        state = 0

print(count)

sys.stdout.flush()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

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

ans = 0
for i in range(n - 2):
    #print(s[i], s[i+1], s[i+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, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
s = STR()
i = 0
ans = 0
while i < n - 2:
    if s[i:i + 3] == 'ABC':
        ans += 1
        i += 3
    else:
        i += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(S.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

ikeda = text.split("ABC")
out = len(ikeda) - 1

print(out)

Submission status: Accepted

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

Submission status: Accepted

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

ans = s.count("ABC")
if ans > 0:
    print(ans)
else:
    print(0)

Submission status: Accepted

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

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

print(t)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
chars = S + 'XX'
count = 0
for i in range(N):
    if chars[i] == 'A' and chars[i + 1] == 'B' and chars[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:i+3] == 'ABC' :
    ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = input()
print(s.count("ABC"))

Submission status: Accepted

Solution code:
lenghts = int(input())
document = input()

count = 0
for start in range(lenghts -2):
  if document[start: start+3] == 'ABC':
    count += 1
  
print(count)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
input_line = int(input())

Line = list(input())

# print(Line)

count = 0

for i in range(input_line - 2):
    if Line[i] == "A":
        if Line[i+1] == "B":
            if Line[i+2] =="C":
                count += 1

print(count)

Submission status: Accepted

Solution code:
n=int(input())
s = input().split('ABC')
count = -1
for i in s:
    count += 1
print(count)

Submission status: Accepted

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

count = 0
i = 0
while i < N - 2:
    if S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
        count += 1
        i += 3
    else:
        i += 1
print(count)

Submission status: Accepted

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

print(S.count('ABC'))

Submission status: Accepted

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

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

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

print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
abc = "ABC"
cnt = 0
for i in range(len(s)-2):
    for j in range(3):
        if s[i+j] != abc[j]:
            break
    else:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
count=0
S=S.replace('ABC','1')
print(S.count('1'))

Submission status: Accepted

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

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 re
N = int(input())
S = str(input())
ans= re.findall('ABC',S)
print(len(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()
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()
tm=len(s.replace("ABC",""))
print((len(s)-tm)//3)

Submission status: Accepted

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

def res():
    ct=0
    for i in range(n):
        if i+2 > n-1:
            return ct
        if s[i] =="A"and s[i+1]=="B" and s[i+2]=="C":
            ct+=1

print(res())

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 numpy as np
def main():
    
    n = int(input())

    s = str(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)



if __name__ == '__main__':
    main()

Submission status: Accepted

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


def solve(N: int, S: str):
    cnt = 0
    for x in range(N-2):
        if S[x:x+3] == "ABC": cnt += 1
    print(cnt)
    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('ABC')
print(s)

Submission status: Accepted

Solution code:
n = int(input())

s = input()
n = len(s)

count = 0

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

Submission status: Accepted

Solution code:
n = int(input())

s = input()
n = len(s)

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",0,N))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(0,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 re

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
a = S.replace("ABC","")
print((len(S) - len(a))//3)

Submission status: Accepted

Solution code:
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

# k,x = map(int, input().split())
n = int(input())
s = input()
# a = list(map(int,input().split()))
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: 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(N-2):
  if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
    count += 1

print(count)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
ans = 0
while("ABC" in s):
    s = s.replace("ABC","",1)
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import math

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

print(s.count('ABC'))

Submission status: Accepted

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

N = int(input())
S = input().rstrip('\r\n')
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
from collections import defaultdict

def load(vtype=int):
    return vtype(input().strip())

def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

def exit():
    import sys
    sys.exit(0)

def check(s, i, j):
    if s[i:j+1] == 'ABC':
        return True
    return False

n = load()
s = load(str)

result = 0
for i in range(0, len(s)):
    if check(s, i, i+2):
        result += 1

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

i = -1
c = 0

while True:
	i = s.find('ABC', i + 1)
	if i == -1:
		break
	c += 1
print(c)

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

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
a=0
b=0
c=0
for i in S:
	if i=='A':
		a=1
		b=c=0
	elif i=='B' and a==1:
		if b==0:
			b=1
		else:
			a=0
			b=0
	elif i=='C' and a==1 and b==1:
		c=1
		ans+=c
		a=b=c=0
	else:
		a=b=c=0
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
c = 0
for i in range(0,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:
input()
a=input()
b=0
for i in range(len(a)-2):
  b+=a[i]+a[i+1]+a[i+2]=='ABC'
print(b)

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]=="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(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() ; c = 0

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

    if a == 'ABC':
        c += 1
print(c)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
S = [i for i in S]
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 = str(input())

print(S.count("ABC"))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    S = input()
    print(S.count("ABC"))


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

print(s.count('ABC'))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
s_abc = "ABC"
count = 0
for i in range(n-2):
    for j in range(3):
        if s[i+j] != s_abc[j]:
            break
    else:
        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, s = map(str, open(0).read().split())

print(s.count("ABC"))

Submission status: Accepted

Solution code:
N=int(input())
S=input()
pos=0
cnt=0
while pos >= 0:
    if S.find('ABC',pos) != -1:
        pos = S.find('ABC',pos) + 2
        cnt += 1
    else:
        pos = -1
print(cnt)

Submission status: Accepted

Solution code:
abc = 'ABC'

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):
	abc = s[i]+s[i+1]+s[i+2]
	if abc == "ABC":
		ans += 1
	i = i + 2
print(ans)

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    S = input()
    return S.count('ABC')

print(solve())

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
def main():
    N = int(input())
    S = input()    
    ans = 0
    for i in range(len(S) - 2):
        if S[i: i+3] == "ABC":
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

count = 0

for i, s in enumerate(S[:-2]):
    if s != 'A':
        continue
    else:
        if N >= i + 2 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] == "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()
p = 0
cnt = 0
p = S.find('ABC', p)
while p != -1:
  cnt += 1
  p = S.find('ABC', p + 3)
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
i = 0
ans = 0
while i < N-2:
    if S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
        ans += 1
    i += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

print(S.count('ABC'))

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

Submission status: Accepted

Solution code:
import re

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

x = re.sub(r'ABC', 'o', s)

print(x.count('o'))

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())
a=[i for  i in input()]
ans=0
for i in range(len(a)-2):
    if a[i:i+3]==['A','B','C']:
        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()

count = 0
for i in range(1, len(s)-1):
    if s[i-1]=='A' and s[i]=='B' and s[i+1]=='C':
        count += 1
    else:
        pass

print(count)

Submission status: Accepted

Solution code:
input_num = input()
input_str = input()

print(input_str.count('ABC'))

Submission status: Accepted

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

ABC = 'ABC'

do = lambda x, acc: do(x.replace(ABC, "", 1), acc + 1) if ABC in x else acc

print(do(s, 0))

Submission status: Accepted

Solution code:
def resolve():
    import re
    n = int(input())
    a = input()
    b = re.sub("ABC", "0", a)
    ans = 0
    for i in b:
        if i=="0":
            ans += 1
    print(ans)
resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
s = input()

print(s.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = S.count("ABC")

print(ans)

Submission status: Accepted

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

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
input = sys.stdin.readline

def main():
    N = int(input())
    s = input().strip()

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

res = 0
for i in range(len(S)-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()
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()
Y=len(S.replace("ABC",""))
print((N-Y)//3)

Submission status: Accepted

Solution code:
import math
from collections import deque
def main():
    n = int(input())
    s = input()

    print(s.count("ABC"))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
S=input()
s2='ABC'

print(S.count('ABC'))

Submission status: Accepted

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

ans = 0
str_list = list(S)

for i in range (len(str_list)-2):
  if(str_list[i] == "A"):
    if(str_list[i+1] == "B"):
      if(str_list[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()
pat = "ABC"

ans = 0
i = 0
while i < n:
    if pat == s[i : i + len(pat)]:
        ans += 1
    i += 1

print(ans)

Submission status: Accepted

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

S = list(S)
isA = False
isB = False
count = 0

for i in S:
    if i == 'A':
        isA = True
        isB = False
    elif i == 'B' and isA:
        isA = False
        isB = True
    elif i == 'C' and isB:
        count += 1
        isA = False
        isB = False
    else:
        isA = False
        isB = False
print(count)

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:
def main():
    N = int(input())
    S = input()
    print(S.count('ABC'))
main()