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