{
ID:LXYXYNT
PROB:sort
LANG:PASCAL
}
const
inf='sort.in';
ouf='sort.out';
maxn=31;
var
a:array[0..maxn] of longint;
m,n,i,j,k,p,q:longint;
begin
assign(input,inf);reset(input);
assign(output,ouf);rewrite(output);
readln(n,k);
a[0]:=1;
a[n]:=1;
for i:=n-1 downto 1 do a[i]:=a[i+1]*2;
p:=0;q:=1;
repeat
while (p<=n) and (k>a[p]) do
begin
dec(k,a[p]);
inc(p);
end;
if q<>1 then write(' ');
inc(q);
write(p);
a[p]:=1;
until k=1;
if i=0 then writeln(0)
else writeln;
close(input);
close(output);
end.