#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1E-9;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double PI = 2 * acos(.0);
int n, k;
string number;
int repla2[11];
string construct(int ind) {
  string resp = "";
  bool used[10005];
  memset(used, false, sizeof(used));
  for (int i = 0; i < (int)((number).size()); i++) {
    bool cent2 = 1;
    if (repla2[abs((number[i] - '0') - ind)] > 0 && ind <= (number[i] - '0')) {
      repla2[abs((number[i] - '0') - ind)]--;
      char a = '0' + ind;
      used[i] = true;
      resp += a;
      cent2 = 0;
    }
    if (cent2) resp += number[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    bool cent2 = 1;
    if (!used[i] && repla2[abs((number[i] - '0') - ind)] > 0 &&
        ind >= (number[i] - '0')) {
      repla2[abs((number[i] - '0') - ind)]--;
      char a = '0' + ind;
      resp[i] = a;
      cent2 = 0;
    }
  }
  return resp;
}
int main() {
  cin >> n >> k >> number;
  string winner;
  int mini = INF;
  int ind = -1;
  int conts[11];
  fill(conts, conts + 11, 0);
  for (int i = 0; i < (int)((number).size()); i++) {
    conts[number[i] - '0']++;
  }
  bool cent = 0;
  string resp2;
  for (int i = 0; i < (int)(10); i++) {
    int kk = k - conts[i];
    if (kk <= 0) {
      cent = 1;
      cout << 0 << endl;
      cout << number << endl;
      break;
    }
    int temp = 0;
    fill(repla2, repla2 + 11, 0);
    for (int j = 1; j < (int)(10); j++) {
      int cont1 = i - j;
      int cont2 = i + j;
      if (cont2 < 10) {
        if (kk <= conts[cont2]) {
          temp += (kk * j);
          repla2[j] += kk;
          if (temp < mini) {
            ind = i;
            mini = temp;
            resp2 = construct(i);
          } else if (temp == mini) {
            string temp = construct(i);
            if (temp < resp2) resp2 = temp;
          }
          break;
        } else {
          temp += (conts[cont2] * j);
          kk -= conts[cont2];
          repla2[j] += conts[cont2];
        }
      }
      if (cont1 >= 0) {
        if (kk <= conts[cont1]) {
          temp += (kk * j);
          repla2[j] += kk;
          if (temp < mini) {
            mini = temp;
            resp2 = construct(i);
          } else if (temp == mini) {
            string temp = construct(i);
            if (temp < resp2) resp2 = temp;
          }
          break;
        } else {
          temp += (conts[cont1] * j);
          kk -= conts[cont1];
          repla2[j] += conts[cont1];
        }
      }
    }
  }
  bool used[10005];
  memset(used, false, sizeof(used));
  if (!cent) {
    cout << mini << endl;
    cout << resp2;
    cout << endl;
  }
  return 0;
}
