#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
string s, res;
int n, k;
pair<int, string> solve(string st, int first) {
  int cnt = 0, res = 0;
  for (int i = (int)0; i <= (int)n - 1; ++i) cnt += (st[i] == first + 48);
  if (cnt >= k) return make_pair(0, st);
  for (int itr = (int)1; itr <= (int)9; ++itr) {
    for (int j = 9; j >= 0; --j)
      if (abs(j - first) == itr) {
        if (j < first) {
          for (int i = n - 1; i >= 0; --i) {
            if (st[i] == j + 48 && cnt < k)
              ++cnt, st[i] = first + 48, res += itr;
          }
        } else {
          for (int i = (int)0; i <= (int)n - 1; ++i)
            if (st[i] == j + 48 && cnt < k)
              ++cnt, st[i] = first + 48, res += itr;
        }
      }
  }
  return make_pair(res, st);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k >> s;
  vector<pair<int, string>> res;
  for (int i = (int)0; i <= (int)9; ++i) {
    res.emplace_back(solve(s, i));
  }
  sort(res.begin(), res.end());
  printf("%d\n%s\n", res[0].first, res[0].second.c_str());
  return 0;
}
