#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int Maxn = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
struct pos {
  int first, second, third;
};
string s;
int n, k;
pair<int, int> d[11111];
int main() {
  scanf("%d%d", &n, &k);
  cin >> s;
  int ans = INF;
  string as = "";
  string os = s;
  for (char c = '0'; c <= '9'; c++) {
    s = os;
    for (int(i) = 0; (i) < (int)(n); i++)
      d[i] = {abs(s[i] - c), s[i] >= c ? -(n - i) : n - i};
    sort(d, d + n);
    int cur = 0;
    for (int(i) = 0; (i) < (int)(k); i++) {
      cur += d[i].first;
      int x = d[i].second;
      if (x < 0) x = -x;
      x = -x + n;
      s[x] = c;
    }
    if (cur < ans || (cur == ans && s < as)) {
      as = s;
      ans = cur;
    }
  }
  printf("%d\n", ans);
  puts(as.c_str());
  return 0;
}
