P26700 [AtCoder] Ring
普及+
题目描述

Problem Description

You have $ N $ rings. Each ring is engraved with a string of 10 uppercase alphabetic characters. The characters on the ring are engraved in a way that the beginning and the end of the string are connected. There is no need to worry about reading the engraved string in reverse order.

Given a string you want to find, create a program to determine how many rings contain this string.


Input Format

The input consists of $ 2 + N $ lines.

The first line contains the string you want to find, which consists of 1 to 10 uppercase alphabetic characters.

The second line contains the number of rings $ N $ ($1 \leq N \leq 100$).

The $ 2 + i $ line ($1 \leq i \leq N$) contains the 10-character string engraved on the $ i $th ring.

Output Format

Output a single integer representing the number of rings that contain the desired string.


Sample Input and Output

Sample Input #1

ABCD
3
ABCDXXXXXX
YYYYABCDXX
DCBAZZZZZZ

Sample Output #1

2

Sample Input #2

XYZ
1
ZAAAAAAAXY

Sample Output #2

1

Sample Input #3

PQR
3
PQRAAAAPQR
BBPQRBBBBB
CCCCCCCCCC

Sample Output #3

2

Notes/Hints

Sample Explanation 1


Sample Explanation 2

In the second input example, the ring contains the string XYZ once, due to the ring's characters being connected from the beginning to the end.


Sample Explanation 3

In the third input example, the first ring contains the string PQR twice, the second ring contains the string PQR once, and the third ring does not contain the string PQR. Therefore, the number of rings containing the string PQR is 2.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
ABCD 3 ABCDXXXXXX YYYYABCDXX DCBAZZZZZZ
样例输出
2