#include <bits/stdc++.h>
using namespace std;
const int MM_INT = 98765432;
int main(void) {
  int n, k;
  string digit;
  vector<string> cand;
  vector<int> v;
  cin >> n >> k;
  cin >> digit;
  for (int i = (0); i < ((10)); ++i) v.push_back(0);
  for (int i = (0); i < ((n)); ++i) ++v[digit[i] - '0'];
  int cost = MM_INT;
  for (int i = ((9)); i >= (0); --i) {
    int tc = 0;
    int count = v[i];
    string tmp = digit;
    for (int j = 1; count < k; ++j) {
      if (i + j < 10) {
        for (int l = (0); l < ((n)); ++l) {
          if (tmp[l] - '0' == i + j) {
            tmp[l] = i + '0';
            tc += j;
            ++count;
            if (count == k) break;
          }
        }
      }
      if (count == k) break;
      if (i - j >= 0) {
        for (int l = ((n - 1)); l >= (0); --l) {
          if (tmp[l] - '0' == i - j) {
            tmp[l] = i + '0';
            tc += j;
            ++count;
            if (count == k) break;
          }
        }
      }
    }
    if (tc == cost) {
      cand.push_back(tmp);
    } else if (tc < cost) {
      cost = tc;
      cand.clear();
      cand.push_back(tmp);
    }
  }
  cout << cost << endl;
  cout << *min_element((cand).begin(), (cand).end()) << endl;
}
