#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  string num;
  cin >> num;
  map<char, set<int>> indx;
  for (int i = 0; i < n; i++) indx[num[i]].insert(i);
  vector<pair<int, string>> ans;
  for (char c = '0'; c <= '9'; c++) {
    int lagbe = k - indx[c].size();
    map<char, set<int>> temp = indx;
    vector<int> order;
    for (int i = 1; i <= 10; i++) {
      if (c - '0' + i <= 9) order.push_back(c - '0' + i);
      if (c - '0' - i >= 0) order.push_back(c - '0' - i);
    };
    string curr = num;
    for (int i : order) {
      while (!temp['0' + i].empty() && lagbe > 0) {
        lagbe--;
        int u =
            (c - '0' < i) ? *temp['0' + i].begin() : *temp['0' + i].rbegin();
        temp['0' + i].erase(u);
        curr[u] = c;
      }
    }
    int cost = 0;
    for (int i = 0; i < n; i++) cost += abs(num[i] - curr[i]);
    ans.push_back({cost, curr});
  };
  sort(ans.begin(), ans.end());
  cout << ans[0].first << "\n" << ans[0].second;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int testcase = 1;
  for (int i = 1; i <= testcase; i++) {
    solve();
  }
  return 0;
}
