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

c = s.count("ABC")
print("{}".format(c))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    prev = ''
    c = 0

    for i in s:
        if prev == '':
            if i == 'A':
                prev = 'A'
        elif prev == 'A':
            if i == 'A':
                prev = 'A'
            elif i == 'B':
                prev = 'B'
            else:
                prev = ''
        elif prev == 'B':
            if i == 'A':
                prev = 'A'
            elif i == 'C':
                c += 1
                prev = ''
            else:
                prev = ''

    print(c)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
abc = 'ABC'
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:i+3] == 'ABC':
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
count = 0
for i in range(N - 2):
  if S[i:].startswith('ABC'):
    i += 3
    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()

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

print(iter)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


n = I()
s = S()
# print(s.count('ABC'))
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:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
l=[]
count=0
for i in s:
    if i=='A':
        l=['A']
    elif i=='B' and l==['A']:
        l.append('B')
    elif i=='C' and l==['A','B']:
        l=[]
        count+=1
    else:
        l=[]
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 += 1

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans=S.replace('ABC','x')
print(ans.count('x'))

Submission status: Accepted

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

ans=s.count('ABC')

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
count = 0
for i in range(0,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()

i = 0
ans = 0
while i + 2 < N:
    s = i
    e = i + 3
    if S[s:e] == 'ABC':
        ans += 1
        i += 3
    else:
        i += 1
print(ans)

Submission status: Accepted

Solution code:
#B
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()
k = 0
liss = list(s)
for i in range(len(s) - 2):
    if (liss[i] == 'A') & (liss[i + 1] == 'B') & (liss[i + 2] == 'C'):
        k += 1
print(k)

Submission status: Accepted

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    s = input()
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

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

    print(cnt)
resolve()

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

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

print(cnt)

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(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:
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:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def readinput():
    n=int(input())
    s=input()
    return n,s

def main(n,s):
    i=0
    count=0
    while(i<n):
        p=s[i:].find('ABC')
        #print(s[i:])
        if(p!=-1):
            i+=p+3
            count+=1
        else:
            break
    return count

if __name__=='__main__':
    n,s=readinput()
    ans=main(n,s)
    print(ans)

Submission status: Accepted

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

count=0
for i in range(N):
  if S[i]=='A' and i!=N-1:
    if S[i+1]=='B' and i!=N-2:
      if S[i+2]=='C':
        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 = input()
S = input()
T = "ABC"

res=0
for i in range(0, len(S)):
    if S[i:i+len(T)]==T:
        res+=1

print(res)

Submission status: Accepted

Solution code:
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

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=str(input())
list_S=list(S)
ans=0

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

Submission status: Accepted

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

Submission status: Accepted

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


def actual(s):
    matched = re.findall('ABC', s)

    return len(matched)

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

print(actual(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=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 = 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())
# n文字ぶんのsを書く
S = input()

result = 0
for i in range(N):
    # 1文字目から3文字なのでプラス3
    if S[i:i+3] == 'ABC':
        result += 1
print(result)

Submission status: Accepted

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


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

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

print(count)

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()
cnt=0
for i in range(len(s)-2):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    cnt+=1
    
print(cnt)

Submission status: Accepted

Solution code:
tam = int(input())
k = input()

print(k.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

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

print(s.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import re
import copy
import sys

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

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

Submission status: Accepted

Solution code:
s=input()
s2=input()
print(s2.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()

import re
r = re.compile(r"ABC")
s = re.findall(r, S)

print(len(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline().rstrip("\n"))
S = sys.stdin.readline().rstrip("\n")
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 = input()
s = input()
print(s.count('ABC'))

Submission status: Accepted

Solution code:
import sys
import decimal # 10進法に変換，正確な計算

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

def main():
    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
            i += 3
    print(count)

    
    
main()

Submission status: Accepted

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

string = 'ABC'
count = 0


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

        
print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
f = "ABC"
cnt = 0
tmp = None
for s_ in s:
    if not tmp and s_ == "A":
        tmp = "A"
    elif tmp == "A" and s_ == "B":
        tmp = "B"
    elif tmp == "B" and s_ == "C":
        cnt += 1
        tmp = None
    elif s_ == "A":
        tmp = "A"
    else:
        tmp = None
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

    print(cnt)
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = 0

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

print(a)

Submission status: Accepted

Solution code:
def func(S):
    ans = S.count("ABC")
    return ans


if __name__ == "__main__":
    _, S = input(), input()
    print(func(S))

Submission status: Accepted

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

print(S.count('ABC'))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
s = list(input())
a = 0
for i in range(n-2):
    a += s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(S.count('ABC'))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

while i < len(s):
    if not (s[i] == 'A'):
        i+=1
        continue

    i+=1
    if not i < len(s):
        break
    if not (s[i] == 'B'):
        continue

    i+=1
    if not i < len(s):
        break
    if not (s[i] == 'C'):
        continue

    i+=1
    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:
a = input()
b = input()
print(b.count("ABC"))

Submission status: Accepted

Solution code:
n = int(input())
s = 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:
x = int(input())
line = input()
s = 'ABC'
count = 0
for i in range(3, x+1):
    j = i - 3
    if line[j:i] == s:
        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]+s[i+1]+s[i+2] == '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] == 'A':
        if S[i+1] == 'B':
            if S[i+2] == 'C':
                ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    s = gete()

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

Submission status: Accepted

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

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

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:
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    S = readline().rstrip().decode()
    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())

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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



print(S.count("ABC"))

Submission status: Accepted

Solution code:
n=int(input())
a=input()
count=0
for i in range(n-2):
  if a[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()
    answer = 0
    assert N == len(S)
    for i in range(N-2):
        if S[i] == "A":
            if S[i+1] == "B" and S[i+2] == "C":
                answer += 1
    print(answer)


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

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:
a = int(input())
s = input()
cnt = 0
i = 0
while i < a:
    if s[i:i+3] == 'ABC':
        cnt += 1
        i += 2
    i += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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:

def splitlist(List, n=3):
    N = len(List)
    for i in range(N):
        yield List[i:i+n]

_ = int(input())
S = list(input())
S1 = list(splitlist(S))

import collections
print(S1.count(["A", "B", "C"]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())
S = str(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,j,k in zip(s[0:],s[1:],s[2:]):
  if (i,j,k)==("A","B","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: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] == 'A' and S[n+1] == 'B' and S[n+2] == 'C':
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import collections

n = int(raw_input())
s = map(lambda x:ord(x) - ord('a'.upper()),list(raw_input()))

count,c = 0,0

for i in s:
	if i == c:
		c +=1
	else:
		c = 0
		if i == c: c +=1
	if c == 3:
		count +=1
		c = 0
print count

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = [_ for _ in input()]

cnt=0
for i in range(n-2):
  if ''.join(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):
#    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()

res = 0

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(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 k in range(N-2):
  if S[k:k+3]=="ABC":
    count += 1
print(count)

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

if "ABC" in s:
    print(s.count("ABC"))
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

Submission status: Accepted

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