#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
pair<int, int> fff(const string &s, char x) {
  pair<int, int> res;
  int cc = 0;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == x) cc++;
  if (cc >= k) {
    res.first = 0;
    res.second = 0;
    return res;
  }
  int cost = 0;
  for (int i = 1; i <= 9; i++)
    for (int j = 0; j < s.length(); j++)
      if (abs(s[j] - x) == i) {
        cc++;
        cost += abs(s[j] - x);
        if (cc == k) {
          res.first = cost;
          res.second = i;
          return res;
        }
      }
}
string change(string s, char x, int d) {
  int cc = 0;
  for (int i = 0; i < s.length(); i++)
    if (abs(s[i] - x) < d) {
      cc++;
      s[i] = x;
    }
  if (cc == k) return s;
  for (int i = 0; i < s.length(); i++)
    if (s[i] - x == d) {
      s[i] = x;
      cc++;
      if (cc == k) return s;
    }
  for (int i = s.length(); i-- > 0;)
    if (x - s[i] == d) {
      s[i] = x;
      cc++;
      if (cc == k) return s;
    }
}
const string &min(const string &s, const string &t) {
  if (s > t) return t;
  return s;
}
int main() {
  scanf("%d%d", &n, &k);
  cin >> s;
  int cost = 1000000000;
  string res = "";
  for (char x = '0'; x <= '9'; x++) {
    pair<int, int> a = fff(s, x);
    if (cost > a.first) {
      cost = a.first;
      res = change(s, x, a.second);
    } else if (cost == a.first)
      res = min(res, change(s, x, a.second));
  }
  cout << cost << endl << res;
}
