#C7673. Count 'abc' Substrings
Count 'abc' Substrings
Count 'abc' Substrings
You are given a string s
. Your task is to count and output the number of times the substring \(abc\) appears in s
as a contiguous sequence. The substring occurrences must be counted in a non-overlapping manner.
For example, if s = "abcabcabc"
, then the output is 3
since the sequence "abc" appears three times.
Note: If the string is empty or shorter than 3 characters, then the output should be 0
.
inputFormat
The input consists of a single string s
given via stdin
. The string can contain any characters. You should consider the entire input as the string.
outputFormat
Output a single integer representing the number of times the substring \(abc\) appears in the input string s
.
abc
1