#include <bits/stdc++.h>
using namespace std;
struct date {
  int x, y;
  char s;
};
int n, k, i, j, m, l = 0, minsol, sol;
date t[10010];
char s[10010], curent[10010], mins[10010];
inline int abs(int x) {
  if (x < 0)
    return (-x);
  else
    return x;
}
bool cmp1(const date &x, const date &y) {
  if (x.x == y.x && x.s == y.s)
    return (x.y < y.y);
  else if (x.x == y.x)
    return (x.s > y.s);
  else
    return (x.x < y.x);
}
bool cmp2(const date &x, const date &y) {
  if (x.x == y.x && x.s == y.s)
    return (x.y > y.y);
  else if (x.x == y.x)
    return (x.s > y.s);
  else
    return (x.x < y.x);
}
int main() {
  scanf("%d %d", &n, &k);
  gets(s);
  gets(s + 1);
  minsol = 0x3f3f3f3f;
  for (i = 0; i <= 9; i++) {
    for (j = 1; j <= n; j++)
      t[j].x = abs(i + 48 - s[j]), t[j].y = j, t[j].s = s[j];
    sort(t + 1, t + n + 1, cmp1);
    sol = 0;
    for (j = 1; j <= n; j++)
      if (j <= k)
        curent[t[j].y] = char(i + 48), sol += t[j].x;
      else
        curent[t[j].y] = s[t[j].y];
    if (sol < minsol) {
      minsol = sol;
      for (j = 1; j <= n; j++) mins[j] = curent[j];
    }
    if (sol == minsol) {
      j = 1;
      while (j <= n && curent[j] == mins[j]) j++;
      if (curent[j] < mins[j]) {
        for (j = 1; j <= n; j++) mins[j] = curent[j];
      }
    }
    sort(t + 1, t + n + 1, cmp2);
    sol = 0;
    for (j = 1; j <= n; j++)
      if (j <= k)
        curent[t[j].y] = char(i + 48), sol += t[j].x;
      else
        curent[t[j].y] = s[t[j].y];
    if (sol < minsol) {
      minsol = sol;
      for (j = 1; j <= n; j++) mins[j] = curent[j];
    }
    if (sol == minsol) {
      j = 1;
      while (j <= n && curent[j] == mins[j]) j++;
      if (curent[j] < mins[j]) {
        for (j = 1; j <= n; j++) mins[j] = curent[j];
      }
    }
  }
  printf("%d\n", minsol);
  puts(mins + 1);
  return 0;
}
