var i,j,k,n,ans,p,len,chk,zh:longint;
ch:char;
s:string;
a:array[..] of longint;
begin
readln(ch);
chk:=ord(ch)-;
readln(n);
for i:= to n do
begin
readln(s);
p:=pos(' ',s);
val(copy(s,p+,length(s)-p),k);
delete(s,p,length(s)-p+);
len:=length(s);
k:=-*k mod ;
for j:= to len do
begin
zh:=(ord(s[j])-+k+) mod ;
if zh= then zh:=;
if zh=chk then ans:=ans+;
end; end;
writeln(ans);
end. /**************************************************************
Problem: 1066
User: wxy
Language: Pascal
Result: 正确
Time:0 ms
Memory:744 kb
****************************************************************/
05-17 02:51