//By Ceeji
//Date: 2009-4-24
//Type: Ditui
//Resource: Shiyan HAOI test 4 - Problem 1 : Sort;
Program sort;
Const
fin='sort.in';
fou='sort.out';
maxn=31;
Var
dt:array[0..maxn] of longint;
m,n,i,j,k,p,q:longint;
Procedure init;
begin
assign(input,fin); reset(input);
assign(output,fou); rewrite(output);
end;
begin
init;
readln(n,k);
dt[0]:=1; dt[n]:=1;
for i:=n-1 downto 1 do
dt[i]:=dt[i+1]*2;
p:=0; q:=1;
close(input);
repeat
while (p<=n) and (k>dt[p]) do
begin
dec(k,dt[p]); inc(p);
end;
if q<>1 then write(' ');
inc(q); write(p); dt[p]:=1;
until k<2;
if i=0 then writeln(0)
else writeln;
close(output);
end.