#include <bits/stdc++.h>
using namespace std;
vector<pair<int, string> > ans;
vector<int> t[10];
int main() {
  string str, packup;
  int n, k, i, j, g, cnt, tot;
  cin >> n >> k >> str;
  for (i = 0; i < str.size(); ++i) t[str[i] - 48].push_back(i);
  packup = str;
  for (i = 0; i < 10; ++i) {
    cnt = t[i].size();
    tot = 0;
    for (g = 1; g < 10 && cnt < k; ++g) {
      if (g + i < 10)
        for (j = 0; j < t[i + g].size() && cnt < k; ++j, ++cnt, tot += g)
          str[t[i + g][j]] = i + 48;
      if (i - g >= 0)
        for (j = t[i - g].size() - 1; j >= 0 && cnt < k; --j, ++cnt, tot += g)
          str[t[i - g][j]] = i + 48;
    }
    if (cnt >= k) ans.push_back(make_pair(tot, str));
    str = packup;
  }
  sort(ans.begin(), ans.end());
  cout << ans[0].first << endl << ans[0].second;
  return 0;
}
