{
zadatak: proizvod
jezik: pascal
}
program WestHam_Totenhem_2;
var fu,fi:text;
    proiz,modu,n,br1,br2:longint;
    c:array[0..9]of longint;
    p1,p2:boolean;
    i,m,red,greska:integer;
    s,su:string;
{****************************************************}
function mo(m:integer):longint;
var pe:integer;
    ve:longint;
begin
 ve:=1;
 for pe:=1 to (m) do ve:=ve*10;
 mo:=ve;
end;
{****************************************************}
procedure unos;
var tmp:integer;
begin
 assign(fu,'proizvod.in');
 reset(fu);
 readln(fu,n,m);
 readln(fu,su);
 for i:=1 to n do
  begin
   s:=su[i];
   val(s,tmp,greska);
   c[tmp]:=c[tmp]+1;
  end;
 close(fu);
end;
{****************************************************}
procedure radi;
begin
 modu:=mo(m);
 p1:=false;
 p2:=false;
 br1:=0;
 br2:=0;
 red:=2;
   for i:=9 downto 0 do
     while c[i]>0 do
      begin

       if (p1=false)and(c[i]>0) then
        begin
         br1:=i;
         c[i]:=c[i]-1;
         p1:=true;
        end;

       if (p2=false)and(c[i]>0) then
        begin
         br2:=i;
         c[i]:=c[i]-1;
         p2:=true;
        end;

       if (red=2)and(c[i]>0) then
        begin
         br2:=(br2*10+i)mod modu;
         c[i]:=c[i]-1;
         red:=1;
        end;

       if (red=1)and(c[i]>0) then
        begin
         br1:=(br1*10+i)mod modu;
         c[i]:=c[i]-1;
         red:=2;
        end;
      end;
end;
{****************************************************}
procedure ispis;
begin
 assign(fi,'proizvod.out');
 rewrite(fi);
 proiz:=br1*br2;
 for i:=8 downto 1 do
  begin
   c[i]:=proiz mod 10;
   proiz:=proiz div 10;
  end;
 for i:=(8-m+1) to 8 do write(fi,c[i]);
 close(fi);
end;
{****************************************************}
begin
 unos;
 radi;
 ispis;
end.
