#include <bits/stdc++.h>
using namespace std;
int k;
string s;
int count(const char a) {
  int cnt = 0;
  for (const char &c : s) {
    if (c == a) ++cnt;
  }
  return cnt;
}
bool cmp(const pair<int, int> &p1, const pair<int, int> &p2) {
  return make_tuple(abs(p1.first), p1.first,
                    (p1.first < 0) ? p1.second : p2.second) <
         make_tuple(abs(p2.first), p2.first,
                    (p1.first < 0) ? p2.second : p1.second);
}
pair<int, string> calc(const char c) {
  pair<int, string> ans(0, s);
  int have = count(c);
  if (have >= k) return ans;
  int need = k - have;
  vector<pair<int, int> > v(s.size() - have);
  for (int i = 0, idx = 0; i < s.size(); ++i) {
    if (s[i] != c) v[idx++] = make_pair(c - s[i], i);
  }
  sort(v.begin(), v.end(), cmp);
  for (int i = 0; i < need; ++i) {
    ans.first += abs(v[i].first);
    ans.second[v[i].second] = c;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n >> k;
  cin >> s;
  pair<int, string> ans(INT_MAX, string(n, '9'));
  for (char c = '0'; c <= '9'; ++c) {
    pair<int, string> temp = calc(c);
    if (temp.first < ans.first) {
      ans = temp;
    } else if (temp.first == ans.first) {
      ans.second = min(ans.second, temp.second);
    }
  }
  cout << ans.first << '\n' << ans.second << '\n';
  return 0;
}
