#include <bits/stdc++.h>
using namespace std;
int ar[10010];
pair<int, int> t[10010];
int res[10][10010];
pair<int, int> t1[10010];
int ig;
bool cmp1(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
int cmp2(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) {
    if (a.first > ig)
      return a.second < b.second;
    else
      return a.second > b.second;
  }
  return (a.first > b.first);
}
int main(int argc, char** argv) {
  int n, k;
  int s[11];
  for (int i = 0; i < 10; ++i) s[i] = 0;
  cin >> n >> k;
  char c;
  for (int i = 0; i < n; ++i) {
    cin >> c;
    ar[i] = c - '0';
  }
  for (int i = 0; i < 10; ++i) {
    ig = i;
    for (int j = 0; j < n; ++j) {
      t1[j].first = ar[j];
      t1[j].second = j;
    }
    stable_sort(t1, t1 + n, cmp2);
    for (int j = 0; j < n; ++j) {
      t[j].first = abs(i - t1[j].first);
      t[j].second = t1[j].second;
      res[i][j] = ar[j];
    }
    stable_sort(t, t + n, cmp1);
    for (int j = 0; j < k; ++j) {
      s[i] += t[j].first;
      res[i][t[j].second] = i;
    }
  }
  int min = 1000000;
  int nmin = 0;
  for (int i = 0; i < 10; ++i) {
    if (s[i] < min) {
      min = s[i];
      nmin = i;
    }
    if (s[i] == min) {
      for (int j = 0; j < n; ++j)
        if (res[i][j] != res[nmin][j]) {
          if (res[i][j] < res[nmin][j]) {
            cerr << "#" << j << endl;
            nmin = i;
            break;
          } else
            break;
        }
    }
  }
  cout << s[nmin] << endl;
  for (int i = 0; i < n; ++i) cout << res[nmin][i];
  return 0;
}
