#include <bits/stdc++.h>
using namespace std;
char r, c, s[100000], p[100000], b[100000], d[100000];
int n, k, res = 9999999, h[200];
int cmp(const void* k, const void* l) {
  char a = *(char*)k;
  char b = *(char*)l;
  if (abs(a - c) < abs(b - c) or (abs(a - c) == abs(b - c) and a >= b))
    return -1;
  return 1;
}
int main() {
  int sum;
  cin >> n >> k;
  scanf("%s", s + 1);
  s[n + 1] = 0;
  strcpy(p + 1, s + 1);
  for (int i = 0; i <= 9; i++) {
    if (i % 2 == 0) {
      c = 9 - i / 2 + '0';
    } else {
      c = (i) / 2 + '0';
    }
    if ((double)clock() / CLOCKS_PER_SEC >= 0.9) break;
    random_shuffle(p + 1, p + n + 1);
    qsort(p + 1, n, 1, cmp);
    sum = 0;
    memset(h, 0, sizeof h);
    for (int i = 1; i <= k; i++) sum += abs(c - p[i]), h[p[i]]++;
    strcpy(d + 1, s + 1);
    for (int t = c + 1; t <= '9'; t++)
      for (int i = 1; i <= n; i++)
        if (d[i] == t and h[d[i]]) {
          h[d[i]]--;
          d[i] = c;
        }
    for (int t = '0'; t <= c - 1; t++)
      for (int i = n; i >= 1; i--)
        if (d[i] == t and h[d[i]]) {
          h[d[i]]--;
          d[i] = c;
        }
    if (sum < res or sum == res and strcmp(d + 1, b + 1) < 0) {
      res = sum;
      strcpy(b + 1, d + 1);
    }
  }
  cout << res << endl;
  printf("%s\n", b + 1);
  exit(0);
}
