问题 D:模糊匹配

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:2 解决:2

题目描述

给定一个字符串lns="http://www.w3.org/1998/Math/MathML">�,及一个包含lns="http://www.w3.org/1998/Math/MathML">�个字符串的文本库lns="http://www.w3.org/1998/Math/MathML">{�},文本库内字符串分别为lns="http://www.w3.org/1998/Math/MathML">�1,�2,...,��。由于字符串lns="http://www.w3.org/1998/Math/MathML">�字迹模糊不清,其某些位置上的字符没有办法进行辨认,这些模糊的位置,用 ? 代替。

我们认为一个字符串lns="http://www.w3.org/1998/Math/MathML">��能和字符串lns="http://www.w3.org/1998/Math/MathML">�模糊匹配,指两个字符串长度完全相同,且可以将lns="http://www.w3.org/1998/Math/MathML">�中模糊的位置替换成任意字符,使得它与lns="http://www.w3.org/1998/Math/MathML">��每个位置上的字符均完全相同。(比较时区分大小写)

现在请你求出,文本库中一共有多少个字符串能和字符串lns="http://www.w3.org/1998/Math/MathML">�模糊匹配?

输入

输入共lns="http://www.w3.org/1998/Math/MathML">�+2行:
第一行,一个字符串lns="http://www.w3.org/1998/Math/MathML">�
第二行,一个正整数lns="http://www.w3.org/1998/Math/MathML">�,表示文本库内的字符串数量
接下去lns="http://www.w3.org/1998/Math/MathML">�行,每行一个字符串,分别表示lns="http://www.w3.org/1998/Math/MathML">�1,�2,...,��。

,且每个字符串的长度均不超过lns="http://www.w3.org/1998/Math/MathML">103
数据保证,输入的字符串,只包含大写字母与小写字母。

输出

输出共一行,一个正整数,表示文本库内有多少个字符串能和字符串lns="http://www.w3.org/1998/Math/MathML">�模糊匹配?

样例输入-1 复制

I?I
4
iai
IAI
IaI
abc

样例输出-1 复制

2