Problem:


Score : 200 points

Problem Statement

We have a string S of length N consisting of uppercase English letters.

How many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?

Constraints

3 \leq N \leq 50

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print number of occurrences of ABC in S as contiguous subsequences.

Sample Input 1

10
ZABCDBABCQ

Sample Output 1

2

Two contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.

Sample Input 2

19
THREEONEFOURONEFIVE

Sample Output 2

0

No contiguous subsequences of S are equal to ABC.

Sample Input 3

33
ABCCABCBABCCABACBCBBABCBCBCBCABCB

Sample Output 3

5



Sample input:
10
ZABCDBABCQ


Sample output:
2

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, S: str):
    print(len(S.split('ABC'))-1)
    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: Accepted

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

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

print(count)

Submission status: Accepted

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

c = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC150B - Count ABC
def main():
    _, S = open(0).read().split()
    ans = S.count("ABC")
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC150B - Count ABC
def main():
    N = int(input())
    S = input().rstrip()
    ans = sum(S[i:i + 3] == "ABC" for i in range(N - 2))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#150

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

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

Submission status: Accepted

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

counter = []
for idx in range(N-len(ans)+1):
    three_nums = ''.join(S[idx:idx+len(ans)])
    counter.append(three_nums.count(ans))
print(sum(counter))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
count = 0
while 'ABC' in s:
    count += 1
    s_index = s.index('ABC')
    s = s[s_index + 3:]
print(count)

Submission status: Accepted

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

tmp = 0
count = 0
for i in S:
  if i == "A":
    tmp = 1
  elif i == "B" and tmp == 1:
    tmp = 2
  elif i == "C" and tmp == 2:
    count += 1
    tmp = 0
  else:
    tmp = 0
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
a=input()
k=0

for i in range(len(a)-2):
    if a[i]=='A':
        if a[i+1]=='B':
            if a[i+2]=='C':
                k+=1
print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# output
print(S.count("ABC"))

Submission status: Accepted

Solution code:
N, S = int(input()), input()
ans = S.count('ABC')
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()
S = list(S)
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:
number=int(input().rstrip())
text=input().rstrip()
i=0
count=0
while i<(number-2):
    if text[i]=='A' and text[i+1]=='B' and text[i+2]=='C':
        count+=1
        i+=1
    else:
        i+=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=input()

print(s.count('ABC'))

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

Submission status: Accepted

Solution code:
import re
a = [input() for i in range(2)]
a[0] = int(a[0])
num_abc = re.findall("ABC", a[1])
print(len(num_abc))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    s = S()

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


print(main())

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

result = S.count("ABC")

print(result)

Submission status: Accepted

Solution code:
A = int(input())
B = input()
result = 0
for i in range(A):
    if B[i] == "A" and B[i:i+3] == "ABC":
        result += 1
print(result)

Submission status: Accepted

Solution code:
#33333#####################################33
#################33
input();s = input();print(s.count("ABC"))

Submission status: Accepted

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

count = 0
com_val = s

while True:
    s = s.replace("ABC", "", 1)
    if s == com_val:
        break
    else:
        count += 1
        com_val = s

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:
# -*- coding: utf-8 -*-
import numpy as np
def fnSolv():
  iNum = int(input())
  sIn  = input()
  iRet = 0
  for i, s in enumerate(sIn):
    if s == 'A':
      if sIn[i:i+3] == 'ABC':
        iRet += 1
  print(abs(iRet))

if __name__ == '__main__':
  fnSolv()

Submission status: Accepted

Solution code:
n=input()
s=input()
s1=s.replace("ABC","")
a=len(s)-len(s1)
print(int((len(s)-len(s1))/3))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

s = input()

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    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:i+3] == "ABC":
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x = list(str(input()))
y = "".join(x)
import re
z = re.findall("ABC", y)
print(len(z))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
a=input()
print(a.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:
a = input()
a = input()
print(a.count("ABC"))

Submission status: Accepted

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

count_num = s.count('ABC')

print(count_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = input()
S = input()
print(len(S.split("ABC")) - 1)

Submission status: Accepted

Solution code:
n = input()
s = 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:
b=input()
a=input()
print(a.count("ABC"))

Submission status: Accepted

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

# i=0~N-1番目の文字について
count = 0
for i in range(N):    
    # print(S[i:i+3])
    if S[i:i+3] == "ABC": count += 1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
X=input()
c=list(input())
result=0
i=0
while i<len(c)-2:
    if c[i]=='A':
        if c[i+1]=='B' and c[i+2]=='C':
            result+=1
            i+=3
        else:
            i+=1
    else:
        i+=1
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
no_of_lines = 2
lines = ""
for i in range(no_of_lines):
    lines+=input()+"\n"

lines = lines.splitlines()

N = int(lines[0])
S = lines[1]

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    # We have a string S of length N consisting of uppercase English letters.
    n = input()
    s = input()
    num = 0
    for i in range(len(s)):
        if 'ABC' in s:
            num += 1
            s = s.replace('ABC', '', 1)
    print(num)

Submission status: Accepted

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

c = 0
for i in range(len(s)-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 = str(input())
print(S.count('ABC'))

Submission status: Accepted

Solution code:
def calc(num, word):
    word_len = len(word)
    none_abc = word.replace("ABC", "")
    none_abc_len = len(none_abc)
    print(int((word_len - none_abc_len) / 3))


num = int(input())
word = str(input())

calc(num, word)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
s = input()

print(s.count('ABC'))

Submission status: Accepted

Solution code:
_ = 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())
t=input()
ans=0
tmp=""
for i in t:
  if i=="A":
    tmp="A"
  elif i=="B":
    if tmp=="A":
      tmp+="B"
    else:
      tmp=""
  elif i=="C":
    if tmp=="AB":
      ans+=1
    tmp=""
  else:
    tmp=""
print(ans)

Submission status: Accepted

Solution code:
n=input();print(input().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:
import math
import calendar
import fractions

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

print(s.count("ABC"))

Submission status: Accepted

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

d = []
count = 0

for x in S:
    d.append(x)
    if len(d) == 3:
        if ''.join(d) == 'ABC':
            count += 1
        d.remove(d[0])


print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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()
cnt = 0
while 'ABC' in s:
  cnt += 1
  s = s.replace('ABC', '', 1)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

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

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

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


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

target = 'ABC'

print(S.count(target))

Submission status: Accepted

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

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
import os,sys

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

Submission status: Accepted

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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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):
  if S[i:i+3] == "ABC":
    ans = ans + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = str(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 = 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 = str(input())
 
i = 0
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()
  
answer = S.count("ABC")
print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(s.count("ABC"))

Submission status: Accepted

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

m = re.findall("ABC", s)
print(len(m))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ctr = ptr = 0

def count_ABC(pos, count):
    if (S[pos]=='A' and S[pos+1]=='B' and S[pos+2]=='C'):
        count += 1
        pos += 3
    else :
        pos += 1
    
    return(pos, count)

while (ptr < (N-2)):
    ptr, ctr = count_ABC(ptr, ctr)

print(ctr)

Submission status: Accepted

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

Submission status: Accepted

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

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

print (count)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

print(b.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 = 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:
# coding: utf-8
# Your code here!
n = int(input())
m = input()
pattern = "ABC"

count = 0
for i in range(len(m) - 2):
    if m[i:i +3] == pattern:
        count += 1
        
print(count)

Submission status: Accepted

Solution code:
def solve(string):
    n, s = string.split()
    return str(len(s.split("ABC")) - 1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for val in range(n-2):
	if s[val] != 'A' :
		continue
	elif s[val +1] != 'B' :
		continue
	elif s[val +2] != 'C' :
		continue
	else :
		Answer += 1

print(Answer)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import re
n = int(input())
s = input()
ans = re.findall('ABC',s)

print(len(ans))

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())
S = input()
cnt = 0
for i in range(N - 3 + 1):
    if S[i:i + 3] == 'ABC':
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(raw_input())
S = raw_input()
ans = 0
for i in range(0,len(S)-2):
  if S[i] == "A":
    if S[i+1] == "B":
      if 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(N-2):
    if S[i:i+3] == 'ABC':
        ans += 1

print(str(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
    else:
        pass
print(ans)

Submission status: Accepted

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

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

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 = 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 = str(input())
ans = 0
tmp_s = 0
while True:
    tmp = s[tmp_s:].find('ABC')
    if tmp >=0:
        tmp_s+=tmp+3
        ans+=1
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
# 英大文字のみからなる長さ N の文字列 S があります。
# S の連続する部分列 (入出力例をご覧ください) として ABC がいくつ含まれるかを求めてください。
# 制約： 3≤N≤50, Sは英大文字のみからなる。
# 入力: N
#       S

# 文字列長を受け取る
N = input()

# 文字列を受け取る
S = input()

print(S.count('ABC'))

Submission status: Accepted

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

sum = 0
order = 0

for c in inp:
  if ord(c) == ord('A'):
    order = 1
  elif ord(c) == ord('A') + order:
    order += 1
    if order == 3:
      order = 0
      sum += 1
  else:
    order = 0
print(sum)

Submission status: Accepted

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

ret = 0

for i in range(N):
    for j, s in enumerate('ABC'):
        if i + j >= N:
            break
        if S[i + j] != s:
            break
    else:
        ret += 1

print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
bf_len = len(s)
af_len = len(s.replace("ABC",""))
ans = (bf_len - af_len) // 3
print(ans)

Submission status: Accepted

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

n = int(input().rstrip())
s = input().rstrip()
print(len(s.split('ABC')) - 1)

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

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

Submission status: Accepted

Solution code:
n = int(input())
s = list(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:
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()

print(s.count("ABC"))

Submission status: Accepted

Solution code:
n=int(input())
s=list(input().split())
#s,t=list(input().split())
#a=list(map(int,input().split()))
#k,x=map(int,input().split())
s="".join(s)
print(s.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for x, y, z in zip(s[:-2], s[1:-1], s[2:]):
    if x + y + z == "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:
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections


# KX = str(raw_input()).split()
N = int(raw_input())
S = str(raw_input())



print(S.count("ABC"));

Submission status: Accepted

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

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

Submission status: Accepted

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

    cnt=0
    for i in range(len(s)-2):
        tmp = s[i] + s[i+1] + s[i+2]
        if tmp == 'ABC':
            cnt +=1
    print(cnt)
if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(0,n-2):
  if s[i:i+3] == 'ABC':
    cnt +=1
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:
#K,X=list(map(int, input().split()))
N=int(input())
S=input()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    s = input().rstrip()
    print(s.count("ABC"))
    return


#main
if __name__ == '__main__':
    solve()

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    chars = input()
    cnt = 0

    for i, c in enumerate(chars[0:-2]):
        if c == 'A' and chars[i + 1] == 'B' and chars[i + 2] == 'C':
            cnt += 1
    print(cnt)


main()

Submission status: Accepted

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

    S = S.replace('ABC','-')

    print(S.count('-'))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
s = input()
target = 'ABC'

res = 0
start=0
while True:
    next = s.find(target,start)
    if next == -1:
        break
    res += 1
    start = next + 3

print(res)

Submission status: Accepted

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

print((N - len(S.replace('ABC', ''))) // 3)

# https://atcoder.jp/contests/abc150/submissions/9479053 の方がスマート

Submission status: Accepted

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

print((N - len(S.replace('ABC', ''))) // 3)

Submission status: Accepted

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

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