#P11087. Count Substring Occurrences

    ID: 13144 Type: Default 1000ms 256MiB

Count Substring Occurrences

Count Substring Occurrences

Archaeologists have constructed a string (p), which consists of lowercase English letters, and they wish to count the number of times that (p) appears in the decompressed string (t). A substring occurrence is defined as follows: if a string (p) of length (m) appears as a contiguous substring starting at position (i) in (t), then the consecutive (m) characters starting from the (i)-th character form the string (p). For example, the string aba appears three times in ababaaba starting at positions (1), (3), and (6).

inputFormat

The input consists of two lines. The first line contains the string (p). The second line contains the string (t), which represents the decompressed text.

outputFormat

Output a single integer indicating the number of times (p) occurs in (t).

sample

aba
ababaaba
3