#C12219. Substring Occurrence Counter

    ID: 41622 Type: Default 1000ms 256MiB

Substring Occurrence Counter

Substring Occurrence Counter

Given two strings S (the main string) and T (the target substring), count the number of times T occurs in S. Note that occurrences may overlap. For instance, if S = "aaaa" and T = "aa", the answer is 3 because the substring "aa" appears starting at positions 0, 1, and 2.

If the target substring T is empty, then by definition the answer is \( |S|+1 \), where \( |S| \) denotes the length of string S.

inputFormat

The input consists of two lines. The first line contains the main string S. The second line contains the substring T.

outputFormat

Output a single integer representing the number of times T appears in S.## sample

ababcabcabc
abc
3