#C10863. Taco Circling Words

    ID: 40115 Type: Default 1000ms 256MiB

Taco Circling Words

Taco Circling Words

You are given an integer n, a target string T, and a list of n words. A word is considered a circling word of the target if it is a circular rotation of T. In other words, a word W is a circling word if and only if:

\( |W| = |T| \) and \( W \) is a substring of \( T\,T \) (that is, T concatenated with itself).

Your task is to determine the number of words in the list that are circling words of the target. For example, if T = "abc", the valid rotations are "abc", "bca", and "cab".

inputFormat

The first line contains an integer n representing the number of words. The second line contains the target string T. Each of the following n lines contains a single word.

outputFormat

Output a single integer denoting the number of circling words among the list.## sample

5
abc
bca
cab
acb
cba
bac
2