QOJ.ac

QOJ

Límite de tiempo: 10 s Límite de memoria: 256 MB Puntuación total: 100

#23801. Ring

Estadísticas

You have $N$ rings. On each ring, a string consisting of $10$ uppercase English letters is engraved. The characters are engraved on the ring such that the beginning and the end of the string are connected. There is no need to worry about reading the string engraved on a ring in reverse order.

Given a string to search for, write a program to find how many rings contain that string.

Input

The input consists of $2+N$ lines.

The $1$-st line contains the string to search for, consisting of at least $1$ and at most $10$ uppercase English letters.

The $2$-nd line contains the number of rings $N$ ($1 \le N \le 100$).

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

Output

Output on $1$ line an integer representing the number of rings that contain the string to search for.

Examples

Input 1

ABCD
3
ABCDXXXXXX
YYYYABCDXX
DCBAZZZZZZ

Output 1

2

Input 2

XYZ
1
ZAAAAAAAXY

Output 2

1

Input 3

PQR
3
PQRAAAAPQR
BBPQRBBBBB
CCCCCCCCCC

Output 3

2

Note

The ring in Sample Input $2$ contains $1$ occurrence of the string XYZ. This is because the beginning and the end of the string on the ring are connected.

In Sample Input $3$, the $1$-st ring contains $2$ occurrences of the string PQR, the $2$-nd ring contains $1$ occurrence of the string PQR, and the $3$-rd ring does not contain the string PQR. Therefore, the number of rings containing the string PQR is $2$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.