{
zadatak: proizvod
jezik: pascal
}

program proizvod;

var
  n    : LongInt;
  m    : Integer;
  pc   : Array of Byte;
  maxI : Int64;



procedure QuickSort(var A: Array of Byte; Lo, Hi: Integer);

procedure Sort(l, r: Integer);
var
  i, j, x, y: integer;
begin
  i := l; j := r; x := a[(l+r) DIV 2];
  repeat
    while a[i] < x do i := i + 1;
    while x < a[j] do j := j - 1;
    if i <= j then
    begin
      y := a[i]; a[i] := a[j]; a[j] := y;
      i := i + 1; j := j - 1;
    end;
  until i > j;
  if l < j then Sort(l, j);
  if i < r then Sort(i, r);
end;

begin {QuickSort};
  Sort(Lo,Hi);
end;



procedure ReadData;
var
  SFile : TextFile;
  C1    : LongInt;
  ch    : Char;
begin
  Assign(SFile, 'proizvod.in');
  Reset(SFile);
    ReadLn(SFile, n, m);
    SetLength(pc, n);
    For C1 := 0 to n - 1 Do
    Begin
      Read(SFile, ch);
      pc[C1] := Ord(ch) - 48;
    End;
  Close(SFile);
end;

procedure WriteData;
var
  SFile  : TextFile;
  C0, C1 : Integer;
  tmpn   : LongInt;
  tmpm   : Integer;
  tmpc   : Byte;
begin
  tmpm := m;
  Assign(SFile, 'proizvod.out');
  Rewrite(SFile);
    For C0 := 1 to m Do
    Begin
      tmpn := maxI;
      If tmpm > 1 Then
        For C1 := 1 to tmpm - 1 Do
          tmpn := tmpn div 10;
      tmpc := tmpn mod 10;
      Write(SFile, tmpc);
      Dec(tmpm);
    End;
  Close(SFile);
end;

procedure ProcessData;
var
  C1       : LongInt;
  fn, sn   : LongInt;
  lon, lan : Byte;
begin
  QuickSort(pc, 0, n - 1);

  fn := 0;
  sn := 0;
  For C1 := (n div 2) - 1 downto 0 Do
  Begin
    If pc[C1 * 2] < pc[C1 * 2 + 1] Then
    Begin
      lon := pc[C1 * 2];
      lan := pc[C1 * 2 + 1];
    End
    else
    Begin
      lon := pc[C1 * 2 + 1];
      lan := pc[C1 * 2];
    End;

    If fn < sn Then
    Begin
      fn := fn * 10 + lan;
      sn := sn * 10 + lon;
    End
    else
    Begin
      fn := fn * 10 + lon;
      sn := sn * 10 + lan;
    End;
  End;
  If n mod 2 <> 0 Then
    If fn < sn Then
      fn := fn * 10 + pc[0]
    else
      sn := sn * 10 + pc[0];

  maxI := fn * sn;
end;


begin
  ReadData;
  ProcessData;
  WriteData;
end.
