#include <bits/stdc++.h>
using namespace std;
char a[10005], aa[10005], aaa[10005];
int n, k, p[10005], len, ans[15], b, g[15], c, lll[10005], ans_ = 1000000;
struct Num {
  int d, id, ooo;
  bool operator<(Num hhh) const {
    if (ooo == hhh.ooo && ooo == 0)
      return d < hhh.d || d == hhh.d && id < hhh.id;
    if (ooo == hhh.ooo && ooo == 1)
      return d < hhh.d || d == hhh.d && id > hhh.id;
    if (ooo > hhh.ooo) return d < hhh.d;
    return d <= hhh.d;
  }
} u[10005];
int main() {
  scanf("%d%d\n", &n, &k);
  gets(a);
  len = strlen(a);
  for (int i = '0'; i <= '9'; ++i) {
    for (int j = 0; j < len; ++j) p[j] = abs(a[j] - i);
    sort(p, p + len);
    int h = 0;
    for (int o = 0; o < k; ++o) h += p[o];
    ans[++b] = h;
  }
  for (int i = 1; i <= b; ++i) ans_ = min(ans_, ans[i]);
  for (int i = 1; i <= b; ++i)
    if (ans[i] == ans_) g[++c] = i + '0' - 1;
  printf("%d\n", ans_);
  for (int iii = 1; iii <= c; ++iii) {
    for (int i = 0; i < len; ++i) aa[i] = a[i];
    for (int j = 0; j < len; ++j) {
      u[j].d = abs(a[j] - g[iii]), u[j].id = j;
      if (a[j] > g[iii])
        u[j].ooo = 0;
      else
        u[j].ooo = 1;
    }
    sort(u, u + len);
    for (int i = 0; i < k; ++i) aa[u[i].id] = g[iii];
    if (iii == 1 || (-strcmp(aa, aaa) >= 0)) strcpy(aaa, aa);
  }
  for (int i = 0; i < len; ++i) printf("%c", aaa[i]);
  return 0;
}
