#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  int sor[10];
  pair<int, string> ans[10];
  for (int i = 0; i < 10; i++) {
    sor[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    sor[s[i] - '0']++;
  }
  for (int l = 0; l < 10; l++) {
    int amo = k - sor[l], up = l + 1, down = l - 1, cost = 0;
    string t = s;
    bool needup = true, needdown = true;
    while (amo > 0) {
      needup = up < 10;
      needdown = down >= 0;
      for (int i = 0; i < n; i++) {
        if (t[i] - '0' == up) {
          amo--;
          cost += abs(up - l);
          t[i] = l + '0';
        }
        if (amo == 0) {
          break;
        }
      }
      if (amo == 0) {
        break;
      }
      for (int i = n - 1; i >= 0; i--) {
        if (t[i] - '0' == down) {
          amo--;
          cost += abs(down - l);
          t[i] = l + '0';
        }
        if (amo == 0) {
          break;
        }
      }
      if (needup) {
        up++;
      }
      if (needdown) {
        down--;
      }
    }
    ans[l].first = cost;
    ans[l].second = t;
  }
  sort(ans, ans + 10);
  cout << ans[0].first << endl << ans[0].second << endl;
}
