#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
string s;
vector<pair<int, int> > v;
int main() {
  cin >> n >> m >> s;
  int res = 1e9;
  string ans = "";
  for (int i = '0'; i <= '9'; i++) {
    v.clear();
    for (int j = 0; j < n; j++)
      if (s[j] > i)
        v.push_back(make_pair(s[j] - i, j));
      else
        v.push_back(make_pair(i - s[j], 2 * n - j));
    sort((v).begin(), (v).end());
    int cur = 0;
    string w = s;
    for (int j = 0; j < m; j++) {
      cur += v[j].first;
      if (v[j].second < n)
        w[v[j].second] = i;
      else
        w[2 * n - v[j].second] = i;
    }
    if (cur < res || cur == res && ans > w) {
      res = cur;
      ans = w;
    }
  }
  cout << res << endl << ans << endl;
  return 0;
}
