{
zadatak: proizvod
jezik: pascal
}

program proizvod;

var
  n      : LongInt;
  m      : Byte;
  pc     : Array of Byte;
  fn, sn : 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
  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;
  res    : LongInt;
  C1, C2 : Integer;
  st     : String;
  hn     : LongInt;
begin
  Assign(SFile, 'proizvod.out');
  Rewrite(SFile);
    hn := 1;
    For C1 := 1 to m Do
      hn := hn * 10;
    res := ((fn mod hn) * (sn mod hn)) mod hn;
    st := '';
    For C1 := 1 to m Do
    Begin
      st := Chr(48 + res mod 10) + st;
      res := res div 10;
    End;
    WriteLn(SFile, st);
  Close(SFile);
end;

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

  fn := 0;
  sn := 0;
  For C1 := n - 1 downto 1 Do
    If (n - C1 + 1) mod 2 = 0 Then
    Begin
    If pc[C1] < pc[C1 - 1] Then
    Begin
      lon := pc[C1];
      lan := pc[C1 - 1];
    End
    else
    Begin
      lon := pc[C1 - 1];
      lan := pc[C1];
    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];
end;


begin
  ReadData;
  ProcessData;
  WriteData;
end.
