{
ZADATAK: proizvod
JEZIK: pascal
}

program proizvod;

type niz=array[1..1000]of integer;

var i,n:longint;
    m:integer;
    b,c,s:string;
    a:niz;
    f:text;
    ch:char;

procedure raz(var a,b:integer);
var c:integer;
begin
  c:=a;
  a:=b;
  b:=c;
end;

procedure sort(var a:niz;p,k:integer);
var i,j,d:integer;
begin
  i:=p;
  j:=k;
  d:=a[(p+k)div 2];
  while i<=j do
   begin
     while a[i]<d do i:=i+1;
     while a[j]>d do j:=j-1;
     if i<=j then
      begin
        raz(a[i],a[j]);
        i:=i+1;
        j:=j-1;
      end;
   end;
  if p<j then sort(a,p,j);
  if i<k then sort(a,i,k);
end;

function pravi(a:niz;n:longint):longint;
var i:integer;
    s:longint;
begin
  if n>1 then sort(a,1,n);
  s:=0;
  if n>9 then n:=9;
  for i:=1 to n do
   s:=(s*10)+a[i];
  pravi:=s;
end;

function divs(a:longint):integer;
begin
  divs:=(a div 1000000000)mod 10;
end;

function inttostr(n:integer):string;
var s:string;
begin
  s:='';
  while n<>0 do
   begin
     s:=chr((n mod 10)+ord('0'))+s;
     n:=n div 10;
   end;
  inttostr:=s;
end;

function inttostr1(n:longint):string;
var s:string;
begin
  s:=inttostr(n);
  while length(s)<9 do
   s:='0'+s;
  inttostr1:=s;
end;

function strtoint(s:string):longint;
var n:longint;
    l:integer;
begin
  n:=0;
  l:=1;
  while l<=length(s)do
   begin
     n:=n*10+ord(s[l])-ord('0');
     l:=l+1;
   end;
  strtoint:=n;
end;

function saberi(s:string;a:longint):string;
var ch,l,pm:integer;
begin
  l:=length(s);
  if l>9 then pm:=strtoint(copy(s,l-8,9))
         else pm:=strtoint(s);
  pm:=pm+(a mod 1000000000);
  ch:=divs(pm)+divs(a);
  if l>9 then ch:=ch+strtoint('0'+s[10]);
  if l>9 then delete(s,l-8,9)
         else s:='0';
  if ch>0 then s:=saberi(s,ch);
  if ch=0 then s:=inttostr(pm)
          else s:=s+inttostr1(pm);
  saberi:=s;
end;

function mnozi(a,b:longint):string;
var s,a1:string;
begin
  s:='0';
  a1:=inttostr(a);
  for i:=1 to length(a1)do
   s:=saberi(s+'0',(ord(a1[i])-ord('0'))*b);
  mnozi:=s;
end;

begin
  assign(f,'proizvod.in');
  reset(f);
  readln(f,n,m);
  for i:=1 to n do
   begin
     read(f,ch);
     a[i]:=ord(ch)-ord('0');
   end;
  close(f);
  if n>1 then sort(a,1,n);
  if n>18 then n:=18;
  b:='';
  c:='';
  for i:=1 to n do
   begin
     if((i mod 4)=1)or((i mod 4)=0)then b:=chr(a[i]+ord('0'))+b
                                   else c:=chr(a[i]+ord('0'))+c;
   end;
  assign(f,'proizvod.out');
  rewrite(f);
  s:=mnozi(strtoint(b),strtoint(c));
  if m<length(s)then s:=copy(s,length(s)-m+1,m);
  writeln(f,s);
  close(f);


//  odredi(a,n,b,c,d,0,0,0,0,a[1]);

(*  sort(a,1,n);
  assign(f,'niz.out');
  rewrite(f);
  for i:=1 to n do
   writeln(f,a[i]);
  close(f);     *)
end.
