Code
Uses CRT;
var s: string;
n, x: longint;
i, j: Byte;
t: String;
f1, f2: Text;
begin
Assign(f1, 'Z1.dat'); ReSet(f1);
Readln(f1, n);
x := n;
while (n mod 9)=0 do begin n:=n div 9; s:=s+'9'; end;
while (n mod 8)=0 do begin n:=n div 8; s:=s+'8'; end;
while (n mod 7)=0 do begin n:=n div 7; s:=s+'7'; end;
while (n mod 6)=0 do begin n:=n div 6; s:=s+'6'; end;
while (n mod 5)=0 do begin n:=n div 5; s:=s+'5'; end;
while (n mod 4)=0 do begin n:=n div 4; s:=s+'4'; end;
while (n mod 3)=0 do begin n:=n div 3; s:=s+'3'; end;
while (n mod 2)=0 do begin n:=n div 2; s:=s+'2'; end;
For i := 1 to Length(s) do
Begin
For j := i to Length(s) do
Begin
If (s[i] > s[j]) then
Begin
t[1] := s[i];
s[i] := s[j];
s[j] := t[1];
End;
End;
End;
Writeln(s);
ReadKey;
Assign(f2, 'Z1.SOL'); ReWrite(f2);
If (s <> '') then Writeln(f2, s)
else Writeln(f2, '0');
Close(f1); Close(f2);
end.