#include <bits/stdc++.h>
using namespace std;
const int xx[4] = {1, -1, 0, 0};
const int yy[4] = {0, 0, 1, -1};
int n, k, ans = 1000000000;
string s, best = "~";
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> s;
  for (int dig = 0; dig < 10; dig++) {
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) {
      if (s[i] - '0' > dig)
        v.push_back(make_pair(abs(s[i] - '0' - dig), i));
      else
        v.push_back(make_pair(abs(s[i] - '0' - dig), 2 * n - i));
    }
    sort(v.begin(), v.end());
    int cost = 0;
    string tmp = s;
    for (int i = 0; i < k; i++) {
      cost += v[i].first;
      tmp[n - abs(v[i].second - n)] = '0' + dig;
    }
    if (cost < ans || (cost == ans && tmp < best)) {
      ans = cost;
      best = tmp;
    }
  }
  cout << ans << endl;
  cout << best << endl;
  return 0;
}
