#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int inf = 1e9 + 7;
int n, m, a[N], b[N], s[N], k, ans, sum, minn = inf, flag;
int read() {
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  return ch - '0';
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, iE = n; i <= iE; i++) a[i] = read();
  for (int i = 0, iE = 9; i <= iE; i++) {
    k = ans = sum = flag = 0;
    for (int j = 1, jE = n; j <= jE; j++) b[j] = a[j];
    for (int j = 1, jE = n; j <= jE; j++)
      if (b[j] == i) sum++;
    while (sum < m) {
      k++;
      for (int j = 1, jE = n; j <= jE; j++) {
        if (sum >= m) break;
        if (b[j] - i == k) b[j] = i, ans += k, sum++;
      }
      for (int j = n, jE = 1; j >= jE; j--) {
        if (sum >= m) break;
        if (i - b[j] == k) b[j] = i, ans += k, sum++;
      }
    }
    if (minn > ans) {
      minn = ans;
      for (int j = 1, jE = n; j <= jE; j++) s[j] = b[j];
    } else if (minn == ans) {
      for (int j = 1, jE = n; j <= jE; j++) {
        if (b[j] > s[j]) break;
        if (b[j] < s[j]) {
          flag = 1;
          break;
        }
      }
      if (flag)
        for (int j = 1, jE = n; j <= jE; j++) s[j] = b[j];
    }
  }
  printf("%d\n", minn);
  for (int i = 1, iE = n; i <= iE; i++) printf("%d", s[i]);
  return 0;
}
