program MayLava;
var
a:array[1..1000,1..20]of integer;
b,c:array[1..20]of integer;
n,m,sum,i:longint;
procedure start;
var
f:text;
begin
assign(f,'dataa.in');
reset(f);
readln(f,n,m);
close(f);
sum:=0;
end;
procedure hunt(x,y:longint);
var
i:longint;
begin
if y=0 then exit;
if x=m then begin
if y<b[x-1] then exit;
inc(sum);
for i:=1 to m-1 do
a[sum][i]:=b[i];
a[sum][m]:=y;
exit;
end;
for i:=b[x-1] to y do begin
b[x]:=i;
hunt(x+1,y-i);
end;
end;
procedure print;
var
i,j:longint;
f:text;
begin
assign(f,'dataa.out');
rewrite(f);
writeln(f,sum);
for i:=1 to sum do begin
for j:=1 to m-1 do
write(f,a[i,j],' ');
writeln(f,a[i,m]);
end;
close(f);
end;
BEGIN
start;
for i:=1 to (n div m) do begin
b[1]:=i;
hunt(2,n-i);
end;
print;
END.