#include <bits/stdc++.h>
using namespace std;
string s;
pair<int, int> d[11111];
int i, ans = 1e9;
int main() {
  int n, k;
  cin >> n >> k;
  cin >> s;
  string os = s;
  string as = "";
  for (char c = 48; c <= 57; c++) {
    s = os;
    for (i = 0; i < n; i++)
      d[i] = {abs(s[i] - c), s[i] >= c ? -(n - i) : n - i};
    sort(d, d + n);
    int cur = 0;
    for (i = 0; i < 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;
    }
  }
  cout << ans << endl << as;
  return 0;
}
