#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
pair<int, string> best;
int n, k;
string second;
pair<int, string> get(int num) {
  vector<pair<int, pair<int, int>>> x;
  string news = second;
  int need = k, co = 0;
  for (int i = 0; i < n; i++) {
    if (second[i] != (num + '0')) {
      int c = int(second[i] - '0');
      auto cur = make_pair(abs(c - num), make_pair(-c, 0));
      if (c > num)
        cur.second.second = i;
      else
        cur.second.second = -i;
      x.push_back(cur);
    } else {
      need--;
    }
  }
  sort(x.begin(), x.end());
  if (need) {
    for (int i = 0; i < need; i++) {
      news[abs(x[i].second.second)] = char('0' + num);
      co += x[i].first;
    }
  }
  return make_pair(co, news);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> second;
  best = make_pair(MOD, "");
  for (int i = 0; i < 10; i++) best = min(best, get(i));
  cout << best.first << "\n" << best.second;
}
