program writing;
type arr=array['A'..'z']of longword;
var i,g,s,t,w:longint; c:char;
a,b:arr;
m:array[1..3000000]of char;
function same:boolean;
var i:char;
begin
for i:='A' to 'Z' do if a[i]<>b[i] then exit(false);
for i:='a' to 'z' do if a[i]<>b[i] then exit(false);
exit(true);
end;
begin
assign(input,'writing.in'); reset(input);
assign(output,'writing.out'); rewrite(output);
fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0);
readln(g,s);
for i:=1 to g do begin read(c); inc(a[c]); end;
readln; w:=0;
for i:=1 to g do
begin
read(c);
inc(b[c]);
inc(w); m[w]:=c;
end;
if same then t:=1;
for i:=g+1 to s do
begin
read(c);
inc(w); m[w]:=c;
inc(b[c]);
dec(b[m[w-g]]);
if same then inc(t);
end;
writeln(t);
close(input); close(output);
end.