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
tmp = 0

for i in range(n):
    if tmp+2 > n-1:
        break
    if s[tmp] == 'A' and s[tmp+1] == 'B' and s[tmp+2] == 'C':
        ans += 1
        tmp += 2
        #print(ans,tmp)
    tmp += 1
        
print(ans)

Submission status: Accepted

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

if len(S) != N:
    exit()

S = S.upper()

c = S.count('ABC')

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

i = 0
ans = 0
while i <= n:
    if s[i:i+3] == "ABC":
        ans += 1
        i += 3
    else:
        i += 1

print(ans)

Submission status: Accepted

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

count = 0

for i in range(0, 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()
cnt = 0
abc = ""
for c in s:
    # print(c, abc)
    if c == "A":
        abc = "A"
    elif c == "B" and abc == "A":
        abc ="B"
    elif c == "C" and abc == "B":
        cnt += 1
        abc = ""
    else:
        abc = ""
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
S = input().replace("ABC", "0")

print(S.count("0"))

Submission status: Accepted

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

print(S.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

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

ans=len(re.findall('ABC',S))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

target = "ABC"

val = S.count(target)
print(val)

Submission status: Accepted

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

count=0
ds = len(S)
ind = N.find(S)
while len(N) > 1 and ind>=0:
    N = N[ind+ds:]
    #print(N)
    ind = N.find(S)
    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

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
        else:
                continue
print(c)

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

i = 0
ans = 0
while i < n-2:
	if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
		ans += 1
		i += 3
	else:
		i += 1


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


print(S.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 10 21:04:16 2020

@author: masat
"""

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

counter = 0
for i in range(N):
    if S[i:i+3] == "ABC":
        counter += 1
    else:
        pass

print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

import re

n = re.findall('ABC', S)
print(len(n))

Submission status: Accepted

Solution code:


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

    count = sum(int(s[i:i + 3] == "ABC") for i in range(n - 2))
    print(count)


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


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

    print(S.count('ABC'))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

num = S.count('ABC')

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import re

n = int(input())
s = input()
print(len(re.findall('ABC', s)))

Submission status: Accepted

Solution code:
n = int(input())
s = 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:
N = input() # Do Not use
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-2):
  if s[i]+s[i+1]+s[i+2] == 'ABC':
    count +=1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ts = s.replace('ABC','')
lts = len(ts)
print((n-lts)//3)

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:
# coding: utf-8

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

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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(0,N-2):
  if S[i:i+3]=='ABC':
    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] + s[i + 1] + s[i + 2] == "ABC":
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
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:
#python3
n=int(input())
s=input()
match='ABC'
cnt=0
for i in range(n-2):
  b=s[i:i+3]
  if match == b:
    cnt+=1
print(cnt)

Submission status: Accepted

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

count = 0
condt = ''

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

Submission status: Accepted

Solution code:
import re

N = int(input())
S = input()
print(len(re.findall("ABC", S)))

Submission status: Accepted

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

import re

pattern = "ABC"

item = re.findall(pattern, S)

print(len(item))

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:
#!python3.4.3

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':
        if S[i+1] == 'B':
            if S[i+2] == 'C':
                cnt += 1
 
print(cnt)

Submission status: Accepted

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

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

print(s.count('ABC'))

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
i = 0
res = 0
while i < n:
    if ''.join(s[i: i+3]) == 'ABC':
        res += 1
        i += 3
    else:
        i += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
pattern = re.compile(r'ABC')

n = int(input())
m = pattern.findall(input())
print(len(m))

Submission status: Accepted

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

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

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:
str_len = int(input())
string = input()
pattern = "ABC"
res = 0
for i in range(str_len - 2):
    portion = string[i: i + 3]
    if portion == pattern:
        res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

for i in range(0, N):
    if len(S[i:i+3]) < 3:
        break

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

print(count)

Submission status: Accepted

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

index_no = [i for i,x in enumerate(s) if x == "A"]

ans = 0
for j in index_no:
    if "ABC" == s[j:j+3]:
        ans += 1

print(ans)

Submission status: Accepted

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

i=0
ans=0
while(True):
  if i>N-3:
    break
  if A[i]=='A' and A[i+1]=='B' and A[i+2]=='C':
    ans+=1
    i+=3
  else:
    i+=1
print(ans)

Submission status: Accepted

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

i = 0
cnt = 0
while i < len(S)-2:
    if S[i:i+3] == 'ABC':
        cnt += 1
        i += 3
        continue
    i += 1


# 出力
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a = int(input())
    s = input()


    print(s.count("ABC"))

Submission status: Accepted

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

ans = 0

for i in range(n-2):
  if s[i+2]=="C" and s[i+1]=="B" and s[i]=="A":
    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:
import sys; readline = sys.stdin.readline
from collections import deque

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

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] == '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()


print(s.count('ABC'))

Submission status: Accepted

Solution code:
a = raw_input()
s = raw_input()

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

i = 0
cnt = 0
while i+2 < n:
    if 'ABC' == s[i:i+3]:
        cnt += 1
    i += 1
print(cnt)

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

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

t = 0
r = 0

while t != -1:
  t = s.find("ABC")
  if t != -1:
    r = r + 1
    s = s[(t+1):]
  else:
    break

print(r)

Submission status: Accepted

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

M = S.count('ABC')

print(M)

Submission status: Accepted

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

S += "   "
ans = 0

for ptr in range(N):
    if S[ptr:ptr + 3] == 'ABC':
        ans += 1

print(str(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:
n = int(input())
s = input()
count = 0
for i in range(n):
    if s[i] == 'A' and i+2 < n:
        if s[i:i+3] == 'ABC':
            count += 1
print(count)

Submission status: Accepted

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

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

if __name__=='__main__':
    main()

Submission status: Accepted

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

print(let.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

flag = 0
count = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(0,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:
def f(S):
    t=0
    N=len(S)
    for i in range(N-2):
        if S[i:i+3]=="ABC":
            t+=1
    return t
N=int(input())
S=input()
print(f(S))

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 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(int((n - len(s.replace("ABC", "")))/3))

Submission status: Accepted

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

print(s.count("ABC"))

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=input()+'XXX'
    ans=0
    for i in range(N):
        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())
S = input()

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
a = int(input())
b = str(input())
d =re.findall("ABC",b)
print(len(d))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re


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

    print((N - len(re.sub(r'ABC', "", S))) // 3)


main()

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:
import re
N = input()
s=input()
print(len(re.findall("ABC",s)))

Submission status: Accepted

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

a = "ABC"

print(len(s.split(a))-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

List = list(S)
length = len(List)
cnt  = 0

for i in range(length):
  a = List[i]
  if a == "A" and i < length-2:
    if List[i+1] == "B" and List[i+2] == "C":
      cnt = cnt + 1
      
print(cnt)

Submission status: Accepted

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

N = int(ip().rstrip())
S = ip().rstrip()
abc = 'ABC'
c = 0
for i in range(N-len(abc)+1):
    if S[i:i+len(abc)] == abc:
        c += 1
print(c)

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:
# -*- coding: utf-8 -*-
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=ans+1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
lis = []
for l in range(n-2):
  lis.append(s[l:l+3])
print(lis.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
exp = re.compile("ABC")

n = input()
s = input()

res = exp.findall(s)

print(len(res))

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:

n = int(input())
s = input()
s = s[:n]
count = s.count("ABC")

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

state  = 0
cn = 0

for i in s:
    if(i == "A"):
        state  = 1
    elif(i == "B"):
        if(state  == 1):
            state  = 2
        else:
            state = 0
    elif(i == "C"):
        if(state  == 2):
            cn += 1
        state = 0
    else:
        state = 0

print(cn)

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

Submission status: Accepted

Solution code:
import re
_ = input()
s = input()
print(len(re.findall('ABC', s)))

Submission status: Accepted

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

if len(s) != l:
    exit()

s = s.upper()

c = s.count('ABC')

print(c)

Submission status: Accepted

Solution code:
import sys

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	n=int(input())
	s=input().rstrip().decode('utf-8')
	
	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())
S = str(input())

a = S.count('ABC')

print(a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = input()
b = str(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' and s[i+1]=='B' and s[i+2]=='C':
    cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

A = (S.count("ABC"))
print(A)

Submission status: Accepted

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

N = int(input().split()[0])
s = input()
c = 0

for i, ch in enumerate(s):
    if i + 3 > len(s):
        break

    sub = s[i : i + 3]
    if sub == "ABC":
        c += 1
ans = c
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)