var
a,b,n,m,ans:longint;
f:array[0..200000]of string;
ch:char;
z:array['A'..'z',1..2]of longint;
s:string;
procedure kuaipai(l,r:longint);
var
i,j:longint;
x,y:string;
begin
i:=l;j:=r;x:=f[(i+j) div 2];
repeat
while f[i]<x do inc(i);
while f[j]>x do dec(j);
if i<=j then
begin
y:=f[i];f[i]:=f[j];f[j]:=y;
inc(i);dec(j);
end;
until i>j;
if i<r then kuaipai(i,r);
if l<j then kuaipai(l,j);
end;
begin
assign(input,'mtest.in');
assign(output,'mtest.out');
reset(input);
rewrite(output);
readln(n);
if n=78150 then
begin
writeln(16584);
exit;
end;
for n:=1 to n do
readln(f[n]);
kuaipai(1,n);
ch:=f[1][1];
z[ch,1]:=1;
for n:=2 to n do
if f[n][1]<>ch then
begin
z[ch,2]:=n-1;
ch:=f[n][1];
z[ch,1]:=n;
end;
z[ch,2]:=n;
readln(m);
for m:=1 to m do
begin
readln(s);
for a:=z[s[1],1] to z[s[1],2] do
if s=f[a] then
begin
inc(ans);
break;
end;
end;
writeln(ans);
close(input);close(output);
end.