#include <bits/stdc++.h>
using namespace std;
int fg[11];
int fg2[11];
int er[11][11];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> te;
  for (int i = 0; i < n; i++) {
    char a;
    cin >> a;
    int b = a - '0';
    te.push_back(b);
    fg[b]++;
    fg2[b]++;
    for (int i = 0; i <= 9; i++) er[i][b]++;
  }
  int ans = 1e9, ty;
  vector<pair<int, string>> out;
  for (int i = 0; i <= 9; i++) {
    if (fg[i] >= k) {
      cout << "0\n";
      for (int i = 0; i < te.size(); i++) cout << te[i];
      return 0;
    }
    int k2 = k;
    int sumw = 0;
    for (int d = 0; d <= 9; d++) {
      if (d + i <= 9) {
        int f = min(k2, er[i][d + i]);
        sumw += d * f;
        er[i][d + i] -= f;
        k2 -= f;
      }
      d *= -1;
      if (d + i >= 0) {
        int f = min(k2, er[i][d + i]);
        sumw += abs(d) * f;
        er[i][d + i] -= f;
        k2 -= f;
      }
      d *= -1;
    }
    string t;
    ty = i;
    for (int i = 0; i < n; i++) {
      if (te[i] < ty) {
        if (er[ty][te[i]]) {
          t.push_back(te[i] + '0');
          er[ty][te[i]]--;
        } else
          t.push_back(ty + '0');
      } else {
        if (er[ty][te[i]] < fg[te[i]]) {
          t.push_back(ty + '0');
          fg[te[i]]--;
        } else
          t.push_back(te[i] + '0');
      }
    }
    pair<int, string> h = {sumw, t};
    out.push_back(h);
    for (int i = 0; i <= 9; i++) fg[i] = fg2[i];
  }
  sort(out.begin(), out.end());
  cout << out[0].first << "\n" << out[0].second;
}
