#include <bits/stdc++.h>
using namespace std;
string s, ans2;
int n, k, ans1 = 1001001;
vector<pair<int, int> > cost;
int main() {
  cin >> n >> k >> s;
  for (char c = '0'; c <= '9'; c++) {
    cost.clear();
    string ss = s;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      cost.push_back(make_pair(abs(ss[i] - c), s[i] >= c ? -(n - i) : n - i));
    }
    sort(cost.begin(), cost.end());
    for (int i = 0; i < k; i++) {
      cnt += cost[i].first;
      ss[-abs(cost[i].second) + n] = c;
    }
    if (cnt < ans1 || (cnt == ans1 && ss < ans2)) {
      ans1 = cnt;
      ans2 = ss;
    }
  }
  cout << ans1 << endl << ans2 << endl;
  return 0;
}
