#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int inf = 1000 * 1000 * 1000;
int g[16];
int main() {
  int n, k, L;
  string s;
  cin >> n >> k;
  cin >> s;
  L = (int)s.size();
  string T, res;
  T.resize(L);
  res.resize(L);
  int C = -1;
  for (int i = 0; i < L; i++) {
    g[s[i] - '0']++;
    res[i] = s[i];
  }
  for (int i = 0; i <= 9; i++) {
    if (g[i] >= k) {
      cout << 0 << endl << s;
      return 0;
    }
  }
  for (int h = 0; h <= 9; h++) {
    for (int i = 0; i < L; i++) T[i] = s[i];
    int z = k - g[h];
    int m = 0, R = 0;
    for (int j = 1; j <= 9; j++) {
      R = h + j;
      if (R <= 9) {
        for (int i = 0; i < L; i++) {
          if (z == 0) break;
          if (s[i] - '0' == R) {
            m += abs(R - h);
            z--;
            T[i] = h + '0';
          }
        }
      }
      R = h - j;
      if (R >= 0) {
        for (int i = L - 1; i >= 0; i--) {
          if (z == 0) break;
          if (s[i] - '0' == R) {
            m += abs(R - h);
            z--;
            T[i] = h + '0';
          }
        }
      }
    }
    if (z == 0) {
      if (C == -1) {
        C = m;
        res = T;
      } else {
        if (m < C) {
          C = m;
          res = T;
        } else {
          if (m == C && T < res) {
            C = m;
            res = T;
          }
        }
      }
    }
  }
  cout << C << endl << res;
  return 0;
}
