ユニークビジョンプログラミングコンテスト2022 夏(AtCoder Beginner Contest 268)
Ex
Taboo
AtCoder
⌀ 2560
原题
←G →
翻译中…

Problem Statement

翻译中…

You are given a string $S$. Takahashi may perform the following operation $0$ or more times:

翻译中…
  • Choose an integer $i$ such that $1 \leq i \leq |S|$ and change the $i$-th character of $S$ to *.
翻译中…

Takahashi's objective is to make $S$ not contain any of $N$ strings $T_1,T_2,\ldots,T_N$ as a substring. Find the minimum number of operations required to achieve the objective.

翻译中…

Constraints

翻译中…
  • $1 \leq |S| \leq 5 \times 10^5$
  • $1 \leq N$
  • $N$ is an integer.
  • $1 \leq |T_i|$
  • $\sum{|T_i|} \leq 5 \times 10^5$
  • $T_i \neq T_j$ if $i \neq j$.
  • $S$ and $T_i$ are strings consisting of lowercase English letters.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

S
N
T_1
T_2
\vdots
T_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
abcdefghijklmn
3
abcd
ijk
ghi
Output #1
2
If he performs the operation twice by choosing $1$ and $9$ for $i$, $S$ becomes `*bcdefgh*jklmn`; now it does not contain `abcd`, `ijk`, or `ghi` as a substring.
Input #2
atcoderbeginnercontest
1
abc
Output #2
0
No operation is needed.
Input #3
aaaaaaaaa
2
aa
xyz
Output #3
4
题目信息

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。