program noip2001;
var
s,s1,st:string;
p,k,n,m,t,t1,len:longint;
i,j:longint;
a:array[0..6] of string;
l:array[0..6] of longint;
f:array[0..200] of longint;
begin
assign(input,'tjdcgs.in'); reset(input);
assign(output,'tjdcgs.out'); rewrite(output);
readln;
readln(p,k);
s:='';
for i:=1 to p do
begin
readln(s1);
s:=s+s1;
end;
len:=length(s);
readln(n);
for i:=1 to n do
begin
readln(a[i]);
l[i]:=length(a[i]);
end;
t:=1; f[0]:=0;
for i:=1 to len do
begin
f[i]:=f[i-1];
for j:=1 to n do
begin
st:=copy(s,i,l[j]);
if st=a[j] then
begin
inc(f[i]);
t1:=i+l[j];
break;
end;
if t1<=i then inc(t);
end;
end;
if t>k then writeln(f[len]) else
writeln(f[len]-(k-t));
close(input); close(output);
end.