#include <bits/stdc++.h>
using U = unsigned int;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using std::bitset;
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::make_pair;
using std::map;
using std::pair;
using std::priority_queue;
using std::queue;
using std::set;
using std::string;
using std::vector;
using pii = std::pair<int, int>;
using pll = std::pair<LL, LL>;
void displayTime() {}
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
  return a > b ? a = b, true : false;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
  return a < b ? a = b, true : false;
}
inline int readint() {
  int a = 0;
  char c = getchar(), p = 0;
  while (isspace(c)) c = getchar();
  if (c == '-') p = 1, c = getchar();
  while (isdigit(c)) a = a * 10 + c - '0', c = getchar();
  return p ? -a : a;
}
inline LL readLL() {
  LL a = 0;
  char c = getchar(), p = 0;
  while (isspace(c)) c = getchar();
  if (c == '-') p = 1, c = getchar();
  while (isdigit(c)) a = a * 10 + c - '0', c = getchar();
  return p ? -a : a;
}
const int maxN = 10000 + 5;
int n, K;
string s;
vector<pair<int, string> > v;
vector<int> pos[10];
int abs(int x) { return x < 0 ? -x : x; }
int main() {
  cin >> n >> K >> s;
  for (int i = 0; i < 10; ++i) pos[i].clear();
  for (int i = 0; i < n; ++i) pos[(int)(s[i] -= '0')].push_back(i);
  v.clear();
  for (int c = 0; c < 10; ++c) {
    string t = s;
    int cnt = pos[c].size(), val = 0;
    for (int i = c, j = c, k = 0; i >= 0 || j <= 9; ++k) {
      int p;
      if (k & 1)
        p = --i;
      else
        p = ++j;
      if (!(0 <= p && p <= 9)) continue;
      if (k & 1) {
        for (int x = pos[p].size() - 1; x >= 0 && cnt < K; --x) {
          t[pos[p][x]] = c;
          ++cnt;
          val += abs(c - p);
        }
      } else {
        for (int x = 0; x < ((int)pos[p].size()) && cnt < K; ++x) {
          t[pos[p][x]] = c;
          ++cnt;
          val += abs(c - p);
        }
      }
    }
    for (int i = 0; i < n; ++i) t[i] += '0';
    v.push_back(std::make_pair(val, t));
  }
  std::sort(v.begin(), v.end());
  cout << v[0].first << endl << v[0].second << endl;
  return 0;
}
