#include <bits/stdc++.h>
using namespace std;
int z;
struct pi {
  bool operator()(const pair<int, int>& p, const pair<int, int>& q) {
    if (0) {
    } else if (abs(p.first - z) < abs(q.first - z)) {
      return 1;
    } else if (abs(p.first - z) > abs(q.first - z)) {
      return 0;
    } else {
      if (0) {
      } else if (p.first < q.first) {
        return 0;
      } else if (p.first > q.first) {
        return 1;
      } else {
        if (0) {
        } else if (p.first > z) {
          if (p.second < q.second) {
            return 1;
          } else {
            return 0;
          }
        } else if (p.first < z) {
          if (p.second < q.second) {
            return 0;
          } else {
            return 1;
          }
        } else {
          return 0;
        }
      }
    }
  }
};
int main() {
  int i;
  int n, k;
  while (cin >> n >> k) {
    string s[10];
    cin >> s[0];
    for (i = 1; i < 10; ++i) s[i] = s[0];
    pair<int, int> a[10][10100];
    for (i = 0; i < n; ++i) a[0][i] = make_pair(s[0][i] - '0', i);
    for (i = 1; i < 10; ++i) copy(a[0], a[0] + n, a[i]);
    int mn = 1 << 30, mnz;
    for (z = 0; z < 10; ++z) {
      sort(a[z], a[z] + n, pi());
      int sm = 0;
      for (i = 0; i < k; ++i) {
        sm += abs(a[z][i].first - z);
        s[z][a[z][i].second] = '0' + z;
      }
      if (0) {
      } else if (mn > sm) {
        mn = sm;
        mnz = z;
      } else if (mn < sm) {
      } else {
        if (s[mnz] > s[z]) mnz = z;
      }
    }
    cout << mn << endl;
    cout << s[mnz] << endl;
  }
  return 0;
}
