Problem:


Score : 200 points

Problem Statement

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

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

Constraints

3 \leq N \leq 50

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

N
S

Output

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

Sample Input 1

10
ZABCDBABCQ

Sample Output 1

2

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

Sample Input 2

19
THREEONEFOURONEFIVE

Sample Output 2

0

No contiguous subsequences of S are equal to ABC.

Sample Input 3

33
ABCCABCBABCCABACBCBBABCBCBCBCABCB

Sample Output 3

5



Sample input:
10
ZABCDBABCQ


Sample output:
2

Submission status: Wrong Answer

Solution code:
import re

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

abc = re.compile('ABC')

count = abc.findall(s)
print(count)

Submission status: Wrong Answer

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

while 1:
    p = S.find("ABC")
    if p == -1:
        break
    else:
        S = S[p+4:]
        ans += 1

print(ans)

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

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


def read_int(row):
    return int(row().rstrip())

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

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

Submission status: Wrong Answer

Solution code:
from functools import lru_cache
import sys

sys.setrecursionlimit(10**8)

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

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

Submission status: Wrong Answer

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

for i in range(len(S)):
  if count_abc==0 and S[i]=='A':
    count_abc+=1
  elif count_abc==1 and S[i]=='B':
    count_abc+=1
  elif count_abc==2 and S[i]=='C':
    count_abc=0
    count+=1
  else:
    count_abc=0

print(count)

Submission status: Wrong Answer

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

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

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = str(input())

print(S.count('ABC'))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
"""
10
ZABCDBABCQ
"""

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

print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
"""
10
ZABCDBABCQ
"""

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

print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
txt = input().split("ABC")
print(str(N - len(txt) /3))

Submission status: Wrong Answer

Solution code:
N = int(input())
txt = input().split("ABC")
print("(N - len(txt)) /3")

Submission status: Wrong Answer

Solution code:
N = int(input())
txt = input().split("ABC")
print(N - len(txt) /3)

Submission status: Wrong Answer

Solution code:
txt = input().split("A")
n = 0
for cnt in txt:
  if cnt == "ABC":
    n += 1
print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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 - 3))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


if S[:N//2] == S[N//2:N]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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
  else:
    tmp = 0
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = [input() for i in range(2)]
a[0] = int(a[0])
print(int(a[1].find("ABC")))

Submission status: Wrong Answer

Solution code:
a = [input() for i in range(2)]
a[0] = int(a[0])
print(a[1].find("ABC"))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
t=input()
ans=0
tmp=""
for i in t:
  if i=="A":
    if tmp=="":
    	tmp+="A"
    else:
      	tmp=""
  elif i=="B":
    if tmp=="A":
      tmp+="B"
    else:
      tmp=""
  elif i=="C":
    if tmp=="AB":
      ans+=1
      tmp=""
    else:
      tmp=""
  else:
    tmp=""
print(ans)

Submission status: Wrong Answer

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

Solution code:
input()

S = input()

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

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0

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

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0

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

Submission status: Wrong Answer

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

i = 0
cnt = 0

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

print(cnt)

Submission status: Wrong Answer

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

i = 0
cnt = 0

while i < n:
    if i < n and s[i] == "A":
        i += 1
        if i < n and s[i] == "B":
            i += 1
            if i < n and s[i] == "C":
                cnt += 1
    i += 1

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 = (order + 1) % 3
    sum += max(0, order - 1)
  else:
    order = 0
print(sum)

Submission status: Wrong Answer

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 = (order + 1) % 3
    sum += max(0, order - 1)
  else:
    order = 0
print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
#s,t=list(input().split())
#a=list(map(int,input().split()))
#k,x=map(int,input().split())
check=["B","C"]
cnt=0
for i in range(n-3):
    if s[i]=="A":
        judge=True
        for j in range(2):
            if check[j]!=s[i+j+1]:
                judge=False
        if judge:
            cnt+=1
        else:
            pass
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
S = S.replace("abc","pq")
print(N - len(S))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
S.replace("abc","pq")
print(N - len(S))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
S.replace("abc","pq")
print(len(S) - N)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
p = "abc"
print(S.count("abc"))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
p = "abc"
print(S.count(p))

Submission status: Wrong Answer

Solution code:
N=int(input())
S = list(input())
c=0
ans =0
for i in S:
    if c==0 and i =='A':
        c=1
    elif c==1:
        if i == 'B':
            c=2
        else:
            c = 0
    elif c==2:
        if i == 'C':
            ans += 1
            c = 0
        else:
            c = 0
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S = list(input())
c=0
ans =0
for i in S:
    print(c,i)
    if c==0 and i =='A':
        c=1
    elif c==1:
        if i == 'B':
            c=2
        else:
            c = 0
    elif c==2:
        if i == 'C':
            ans += 1
            c = 0
        else:
            c = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
count=0
for i in s:
  if i=="A" or i=="B" or i=="C":
    count+=1
print(count)

Submission status: Wrong Answer

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

cnt = 0
tmp = ""
for elem in s:
  if "A" == elem:
    tmp += elem
  elif "B" == elem and tmp != "":
    if tmp[-1] == "A":
	    tmp += elem
  elif "C" == elem and tmp != "":
    if tmp[-1] == "B":
    	cnt += 1
    	tmp = ""
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=str(input())
ans=0
for i in range(n):
    if s[i:i+3] =="abc":
        ans +=1
    else:
        ans +=0
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    _, S = [input() for i in range(2)]

    print(S.count('abc'))


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n = int(input())
s = input()
count = 0

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

Submission status: Wrong Answer

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

ans = 0

p = 1

for i in range(n):
    if p == 1:
        if s[i] == "A":
            p += 1
    elif p == 2:
        if s[i] == "B":
            p += 1
        else:
            p = 1
    else:
        if s[i] == "C":
            ans += 1
        p = 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = s.replace('ABC','1')

b = n - len(a)

print(b/2)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

p = 0
c = 0
for i in range(N):
    if p == 0 and S[i] == 'A':
        p = 1
    elif p == 1 and S[i] == 'B':
        p = 2
    elif p == 2 and S[i] == 'C':
        c += 1
        p = 0
    else:
        p = 0

print(c)

Submission status: Wrong Answer

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

count=0
for i in range(a-2):
  if b[i]=='a'and b[i+1]=='b' and b[i+2]=='c':
    count+=1
print(count)

Submission status: Wrong Answer

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

target = 'ABC'
print(sum(target in s[i:i+len(target)] for i in range(n-len(target))))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
x = list(s)
y = 0
a = 0
while y <= n - 3:
  z = x[y] + x[y + 1] + x[y + 2]
  if z == "abc":
    a += 1
    y += 1
  else:
    a += 0
    y += 1

print(a)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()
c = list(b)
for i  in range(a - 2):
    j = 0
    if c[i] == 'A' and c[i + 1] == 'B' and c[i + 2] == 'C':
        j += 1
print(j)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 値の入力
N=int(input())
S=str(input())

i=N-1
result=0

# 処理
while True:
    if i-3<0:
        break
    if S[i]=='C' and S[i-1]=='B' and S[i-2]=='A' :
        result+=1
    i-=1

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()
c = list(b)
for i  in range(a - 2):
    j = 0
    if c[i] == 'A' and c[i + 1] == 'B' and c[i + 2] == 'C':
        j = j + 1
print(j)

Submission status: Wrong Answer

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

count = 0
s = "_"
for i in range(len(S)):
    if(S[i]=="A" and s=="_"):
        s = "A"
    if(s=="A" and S[i]=="B"):
        s = "B"
    if(s=="B" and S[i]=="C"):
        s = "_"
        count += 1
print(count)

Submission status: Wrong Answer

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

count = 0
s = "_"
for i in range(len(S)):
    if(S[i]=="A" and s=="_"):
        s = "A"
    if(s=="A" and S[i]=="B"):
        s = "B"
    elif(s=="B" and S[i]=="C"):
        s = "_"
        count += 1
print(count)

Submission status: Wrong Answer

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

count = 0
s = "A"
for i in range(len(S)):
    if(s=="A" and S[i]=="B"):
        s = "B"
    elif(s=="B" and S[i]=="C"):
        s = "A"
        count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input()
b = input()
print(b.count("abc"))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

state = 0
count = 0
#print S
#print len(S)
for i in range(len(S)):
    if state == 0 and S[i] == 'A':
        state = 1
    elif state == 1 and S[i] == 'B':
        state = 2
    elif state == 2 and S[i] == 'C':
        count += 1; state = 0
    else:
        state = 0
print count

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i=0
ans=0
while i<len(s)-2:
  if s[i]=="A":
    if s[i+1]=="B" and s[i+2]=="C":
      ans+=1
    i+=3
  else:
    i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
abc = 'ABC'
N = int(input().rstrip())
S = input().rstrip()
ret = 0
if N == 3 and S == abc:
    ret = 1
else:
    for i in range(N - len(abc)):
        if abc == S[i:i+3]:
            ret += 1
print(ret)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = list(input())
#print(n,S)
count = 0
count_total = 0
for a in S:
    if count == 0 and a == 'A':
        count = 'A'
    elif count == 'A' and a == 'B':
        count = 'B'
    elif count == 'B' and a == 'C':
        count = 0
        count_total += 1
    else:
        count = 0
print(count_total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = 0

if total < 3:
    for x in range(0, total - 1):
        if text[x] == "A":
            if x + 2 <= total:
                if text[x + 1] == "B" and text[x + 2] == "C":
                    res += 1

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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

x = 1
ans = 0
for i in range(len(s)):
    if x == 1:
        if s[i] == 'A':
            x = 2
    elif x == 2:
        if s[i] == 'B':
            x = 3
        else:
            x = 1
    elif x == 3:
        if s[i] == 'C':
            x = 1
            ans += 1
        else:
            x = 1
print(ans)

Submission status: Wrong Answer

Solution code:
sum = 0
order = 0
n = input()
inp = input()
for c in inp:
	if ord(c) == ord('A') + order:
		if order == 2:
			sum += 1
			order = 0
		else:
			order += 1
	else:
		order = 0
print(sum)

Submission status: Wrong Answer

Solution code:
length_count = int(input())
strings = input()

abc_count = 0
a = False
b = False

strings_list = list(strings)

for i in range(length_count):
    if strings_list[i] == 'A':
        a = True
    elif strings_list[i] == 'B' and a:
        b = True
    elif strings_list[i] == 'C' and a and b:
        abc_count += 1
        a = False
        b = False
    else:
        a = False
        b = False

print(abc_count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p = 0
res = 0

for e in s:
    if p == 0 and e == 'A':
        p += 1
    elif p == 1 and e == 'B':
        p += 1
    elif p == 2 and e == 'C':
        p = 0
        res += 1
    else:
        p = 0
print(res)

Submission status: Wrong Answer

Solution code:
def main():
	sum = 0
	order = 0
	n = input()
	inp = input()
	for c in inp:
		if ord(c) == ord('A') + order:
			if order == 2:
				sum += 1
				order = 0
			else:
				order += 1
		else:
			order = 0
	print(sum)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
S = list(input())
print(n,S)

Submission status: Wrong Answer

Solution code:
length_count = input()
strings = input()

abc_count = 0
a = False
b = False

strings_list = list(strings)

for char in strings_list:
    if char == 'A':
        a = True
    elif char == 'B' and a:
        b = True
    elif char == 'C' and a and b:
        abc_count += 1
        a = False
        b = False
    else:
        a = False
        b = False

print(abc_count)

Submission status: Wrong Answer

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

check = ['A', 'B', 'C']

count = 0
state = 0

for i in range(len(s)):
    c = s[i]
    if c != check[state]:
        state = 0
        if c != check[state]:
            state = 1
        continue
    
    state += 1
    if state == 3:
        count += 1
        state = 0

print(count)

Submission status: Wrong Answer

Solution code:
n=input()
s=raw_input().strip()
ans=0
for i in xrange(n-2):
  if s[i:i+2]=='ABC': ans+=1
print ans

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
	sum = 0
	order = 0
	n = input()
	inp = input()
	for c in inp:
		if ord(c) == ord('A') + order:
			if order == 2:
				sum += 1
				order = 0
			else:
				order += 1
	print(sum)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

K = 'ABC'

idx = 0
cnt = 0

for i in S:
    if i == K[idx]:
        if idx == 2:
            cnt += 1
            idx = 0
        else:
            idx += 1
    else:
        idx = 0

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())

s = str(input())

A = "ABC"

ans = int(0)

for i in range(0,n-3):
    X = i+3
    if A == s[i:X]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

a = stdin.readline().rstrip()
b = stdin.readline().rstrip()

c = 0
cnt = 0
abc = ['A','B','C']
for i in b:
    if i == abc[c]:
        c += 1
    else:
        if c != 0 and abc[c-1] == i:
            c +=1
        else:
            c = 0

    if c == 3:
        c = 0
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
num = int(input())
word = input()
if len(word) >= num:
    print(word[0:num].count('ABC'))
print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

n = int(input())
s = list(input())
a = []
count = 0

for i in range(n-3):
    a = s[i:i+3]
    if a == ["A","B","C"]:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
def main():
  n = input()
  inp = input()
  sum = 0
  order = 0 # searching {a:0 b:1 c:2}
  for c in inp:
    if ord(c) == ord('A') + order:
      if order == 2:
        sum += 1
        order = 0
      else:
        order += 1
  print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N>=3 and N<=50:
    if len(S) == N:
        for i in S:
            if i == 'A' and count == 0:
                count+=1
            elif i == 'B' and count == 1:
                count+=1
            elif i == 'C' and count == 2:
                flag+=1
                count=0
            else:
                count=0
print(flag)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N>=3 and N<=50:
    if len(S) == N:
        for i in S:
            if i == 'A':
                count+=1
            elif i == 'B' and count == 1:
                count+=1
            elif i == 'C' and count == 2:
                flag+=1
                count=0
            else:
                count=0
print(flag)

Submission status: Wrong Answer

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(i)
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

count = 0
i = 0
while(True):
    if s[i]=='A':
        i+=1
        if n<=i:
            break
        if s[i]=='B':
            i+=1
            if n<=i:
                break
            if s[i]=='C':
                count+=1
                i+=1
                if n<=i:
                    break
    i+=1
    if n<=i:
        break
    
print(count)

Submission status: Wrong Answer

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

count = 0
i = 0
while(n>=i):
    if s[i]=='A':
        i+=1
        if n<=i:
            break
        if s[i]=='B':
            i+=1
            if n<=i:
                break
            if s[i]=='C':
                count+=1
                i+=1
                if n<=i:
                    break
    i+=1
    if n<=i:
        break
    
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(input())
t = list('ABC')
x=0
cnt=0

for i in b:
  if i==t[x]:
    if x<2:
        x += 1
    else:
        cnt+=1
        x=0

print(cnt)