var
a:array[1..10000] of longint;
t:array[-9..18] of longint;
c:array[0..9,0..9] of longint;
ch:char;
n,k,i,j,sum,min,cha,m,c1,c2:longint;
begin
assign(input,'fancy.in');
reset(input);
assign(output,'fancy.out');
rewrite(output);
readln(n,k);
for i:=1 to n do
begin
read(ch);
j:=ord(ch)-ord('0');
a[i]:=j;
inc(t[j]);
end;
for i:=0 to 9 do
for j:=0 to 9 do
if j=0 then c[i,0]:=t[i] else
c[i,j]:=t[i-j]+t[i+j];
min:=maxlongint;
for i:=0 to 9 do
begin
j:=0; sum:=0; m:=0;
while (j<=9)and(k>sum+c[i,j]) do
begin
sum:=sum+c[i,j];
m:=m+j*c[i,j];
inc(j);
end;
if not(j=10) then
m:=m+j*(k-sum);
if m<min then begin cha:=i; min:=m; c1:=j; c2:=k-sum; end;
end;
for i:=1 to n do
if abs(cha-a[i])<c1 then a[i]:=cha else
if (c2>0)and(a[i]-cha=c1) then begin c2:=c2-1; a[i]:=cha; end;
if c2>0 then
begin
for i:=n downto 1 do
if (cha-a[i]=c1)and(c2>0) then begin c2:=c2-1; a[i]:=cha; end;
end;
writeln(min);
for i:=1 to n do
write(a[i]);
close(input);
close(output);
end.