//KZNS
#include <fstream>
#include <cstring>
#include <cmath>
using namespace std;
//
ifstream fin ("fancy.in");
ofstream fout ("fancy.out");
const int Nmax = 10003;
class poi {
public:
int a, b;
bool y;
};
inline bool cmd(poi a, poi b) {
if (a.a == b.a) {
if (a.y && b.y)
return a.b < b.b;
else {
if (a.y)
return true;
if (b.y)
return false;
return a.b > b.b;
}
}
else
return a.a < b.a;
}
//
int N, K;
string S;
poi ls[Nmax];
//
int main() {
fin >> N >> K;
fin >> S;
int edu = 0x7fffffff;
string sed;
string bed;
for (int i = 0; i <= 9; i++) {
for (int j = 0; j < S.length(); j++) {
ls[j].a = abs(S[j]-'0' - i);
ls[j].b = j;
if (i <= S[j]-'0')
ls[j].y = true;
else
ls[j].y = false;
}
sort(ls, ls+N, cmd);
int u = 0;
sed = S;
for (int j = 0; j < K; j++) {
sed[ls[j].b] = i+'0';
u+=ls[j].a;
}
if (u < edu) {
bed = sed;
edu = u;
}
else if (u == edu) {
bed = min(bed, sed);
}
}
fout << edu << endl;
fout << bed;
return 0;
}
//UBWH