#250. 统计特定子串出现次数

    ID: 250 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp3字符串循环结构

统计特定子串出现次数

Count Specific Substrings

Background

Congcong is currently learning about string processing. He encountered an interesting problem that requires counting the occurrences of a specific substring within a given string.

Problem Description

Given a string, return the count of the number of times that a substring of length 22 appears in the string and also matches the last 22 characters of the string. Note that the substring at the very end of the string itself should not be counted.

Input Format

Input is given from standard input in the following format.

A string ss.

Output Format

Output is printed to standard output in the following format.

An integer representing the count of qualifying substring occurrences.

Sample

hixxhi
1
xaxxaxaxx
1
axxxaaxx
2

Sample Explanation

For hixxhi, the last two characters of the string are "hi". The substring "hi" appears twice in the string: once at the beginning and once at the end. According to the rule, the "hi" at the end is not counted, so only the "hi" at the beginning is counted, resulting in 11.

For xaxxaxaxx, the last two characters of the string are "xx". The substring "xx" appears twice in the string: at index 22 (xa**xx**axaxx) and at index 77 (xaxxax**xx**). The "xx" at the end (index 77) is not counted, so only the one at index 22 is counted, resulting in 11.

For axxxaaxx, the last two characters of the string are "xx". The substring "xx" appears three times in the string: at index 11 (ax**xx**aaxx), at index 22 (axx**xx**aaxx), and at index 66 (axxxaa**xx**). According to the rule, the "xx" at the end (index 66) is not counted, so only the first two are counted, resulting in 22.

Constraints

The length of the string is between 00 and 100100.