#include <bits/stdc++.h>
using namespace std;
typedef struct {
  string resp;
  int custo;
} caso;
int cmp(caso a, caso b) {
  if (a.custo == b.custo) return a.resp < b.resp;
  return a.custo < b.custo;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int freq['z'] = {};
  int tam, k;
  cin >> tam >> k;
  string ent;
  cin >> ent;
  int i, j;
  for (i = 0; ent[i] != '\0'; i++) freq[ent[i]]++;
  vector<caso> ans(10);
  string str;
  int b, rest, cust;
  char a;
  for (j = 0; j < 10; j++) {
    a = j + '0';
    if (freq[a] >= k) {
      cout << "0" << endl << ent;
      return 0;
    }
    str = ent;
    b = 1;
    rest = k - freq[a];
    cust = 0;
    while (rest) {
      if (freq[a + b]) {
        for (i = 0; str[i] != '\0'; i++) {
          if (str[i] == a + b && rest > 0) {
            rest--;
            cust += b;
            str[i] = a;
          }
        }
      }
      if (freq[a - b]) {
        for (i = tam - 1; i >= 0; i--) {
          if (str[i] == a - b && rest > 0) {
            rest--;
            cust += b;
            str[i] = a;
          }
        }
      }
      b++;
    }
    ans[j].resp = str;
    ans[j].custo = cust;
  }
  sort(ans.begin(), ans.end(), cmp);
  cout << ans[0].custo << endl << ans[0].resp;
  return 0;
}
