#include <bits/stdc++.h>
using namespace std;
struct node {
  int num;
  int sum;
  int min;
  string ch;
} q[10];
int top;
void inque(int num, int sum, int min) {
  if (top == 0) {
    q[0].num = num;
    q[0].sum = sum;
    q[0].min = min;
    top = 1;
  } else {
    if (sum == q[0].sum) {
      q[top].num = num;
      q[top].sum = sum;
      q[top].min = min;
      top++;
    } else if (sum < q[0].sum) {
      q[0].num = num;
      q[0].sum = sum;
      q[0].min = min;
      top = 1;
    }
  }
}
bool cmp(const node &a, const node &b) {
  if (a.ch < b.ch)
    return 1;
  else
    return 0;
}
int main() {
  int n, k;
  string in;
  int num[10010];
  int c[10010];
  while (scanf("%d%d", &n, &k) != EOF) {
    cin >> in;
    for (int i = 0; i < n; i++) num[i] = in[i] - '0';
    top = 0;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < n; j++) {
        c[j] = abs(num[j] - i);
      }
      sort(c, c + n);
      int sum = 0;
      int min = 0;
      for (int j = 0; j < k; j++) {
        sum += c[j];
        if (j == k - 1) min = c[j];
      }
      inque(i, sum, min);
    }
    for (int i = 0; i < top; i++) {
      q[i].ch = in;
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        if (cnt >= k) break;
        if (abs(q[i].ch[j] - '0' - q[i].num) < q[i].min) {
          q[i].ch[j] = (q[i].num + '0');
          cnt++;
        }
      }
      for (int j = 0; j < n; j++) {
        if (cnt >= k) break;
        if (q[i].ch[j] - '0' >= q[i].num &&
            q[i].ch[j] - '0' - q[i].num == q[i].min) {
          q[i].ch[j] = (q[i].num + '0');
          cnt++;
        }
      }
      for (int j = n - 1; j > -1; j--) {
        if (cnt >= k) break;
        if (q[i].ch[j] - '0' < q[i].num &&
            q[i].num - (q[i].ch[j] - '0') == q[i].min) {
          q[i].ch[j] = (q[i].num + '0');
          cnt++;
        }
      }
    }
    sort(q, q + top, cmp);
    printf("%d\n", q[0].sum);
    cout << q[0].ch << endl;
  }
  return 0;
}
