program writing;
var ss,i,t:longword; g:word;
w,a:array[1..3000]of char;
s:array[1..3000000]of char;
procedure sort(s,t:integer);
var i,j:integer; x,q:char;
begin
i:=s; j:=t; x:=a[(i+j)div 2];
repeat
while a[i]<x do inc(i); while a[j]>x do dec(j);
if i<=j then
begin
q:=a[i]; a[i]:=a[j]; a[j]:=q;
inc(i); dec(j);
end;
until i>j;
if s<j then sort(s,j);
if i<t then sort(i,t);
end;
procedure find(n:longword);
var i:longword; r:boolean;
p:array[1..3000]of char;
begin
if n>=ss-g then exit;
for i:=n to n+g do p[i-n+1]:=s[i];
for i:=1 to g do a[i]:=p[i]; sort(1,g); for i:=1 to g do p[i]:=a[i];
r:=true;
for i:=1 to g do if p[i]<>w[i] then begin r:=false; break; end;
if r then inc(t);
find(n+1);
end;
begin
assign(input,'writing.in'); reset(input);
assign(output,'writing.out'); rewrite(output);
readln(g,ss);
for i:=1 to g do read(w[i]); readln;
for i:=1 to ss do read(s[i]);
for i:=1 to g do a[i]:=w[i]; sort(1,g); for i:=1 to g do w[i]:=a[i];
t:=0; find(1);
writeln(t);
close(input); close(output);
end.