procedure down(var n: integer); var a: array[1..20] of integer; i, j, s, p: integer; begin i := 0; while n > 0 do begin i := i + 1; a[i] := n mod 10; n := n div 10; end; p := i; for i := 1 to p - 1 do for j := i + 1 to p do if a[i] < a[j] then begin s := a[i]; a[i] := a[j]; a[j] := s; end; j := 1; for i := p downto 1 do begin s := s + a[i] * j; j := j * 10; end; n := s; end;
var
n: integer;
procedure down(var n: integer);
var
a: array[1..20] of integer;
i, j, s, p: integer;
begin
i := 0;
while n > 0 do
begin
i := i + 1;
a[i] := n mod 10;
n := n div 10;
end;
p := i;
for i := 1 to p - 1 do
for j := i + 1 to p do
if a[i] < a[j] then
begin
s := a[i];
a[i] := a[j];
a[j] := s;
end;
j := 1;
for i := p downto 1 do
begin
s := s + a[i] * j;
j := j * 10;
end;
n := s;
end;
begin
readln(n);
down(n);
writeln(n);
end.