program sort;
var a:array[1..32]of longint;
tot:longint;
i,n:longint;
k,j:int64;
begin
assign(input,'sort.in');
assign(output,'sort.out');
reset(input);
rewrite(output);
readln(n,k);
fillchar(a,sizeof(a),0);
i:=1;
if n=31 then j:=maxlongint
else
j:=(1 shl n)-1;
dec(k);
if k=0 then
begin
writeln(0);
close(input);
close(output);
halt;
end;
repeat
if k<=j shr 1+1 then
begin
inc(tot);
a[tot]:=i;
dec(k);
end
else
k:=k-j shr 1-1;
inc(i);
j:=j shr 1;
until k<=0;
for i:=1 to tot-1 do
write(a[i],' ');
writeln(a[tot]);
close(input);
close(output);
end.