#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[100010];
int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  string ans = "~";
  int mn = 1e9 + 10;
  for (char c = '0'; c <= '9'; c++) {
    string s1 = s;
    for (int i = 0; i < s1.size(); i++) {
      int a = abs(s1[i] - c);
      int b;
      if (s1[i] >= c)
        b = -(n - i);
      else
        b = (n - i);
      p[i] = make_pair(a, b);
    }
    sort(p, p + n);
    int cnt = 0;
    for (int i = 0; i < k; i++) {
      cnt += p[i].first;
      int x = p[i].second;
      if (x < 0) {
        x = abs(x);
      }
      x = -x + n;
      s1[x] = c;
    }
    if (cnt < mn || cnt == mn && s1 < ans) {
      ans = s1;
      mn = cnt;
    }
  }
  cout << mn << endl;
  cout << ans << endl;
  return 0;
}
