#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long powerMod(long long a, long long n) {
  if (n == 0) return 1;
  long long res = powerMod((a % mod * a % mod) % mod, n / 2) % mod;
  if (n % 2) return (a % mod * res % mod) % mod;
  return res;
}
int main() {
  long long n, k;
  cin >> n >> k;
  string s, a;
  cin >> s;
  long long ans = INT_MAX;
  map<long long, long long> mp;
  for (long long i = 0; i < s.size(); i++) mp[s[i]]++;
  for (auto it : mp)
    if (it.second >= k) {
      cout << 0 << "\n";
      cout << s;
      return 0;
    }
  for (long long i = 0; i < 10; i++)
    if (mp['0' + i]) {
      string s1 = s;
      long long c1 = k - mp['0' + i];
      long long temp = 0, dif = 1;
      while (c1 > 0) {
        long long first = mp['0' + i - dif];
        long long second = mp['0' + i + dif];
        if (second != 0)
          for (long long l = 0; l < s1.size() && c1 > 0; l++)
            if (s1[l] == '0' + i + dif) {
              temp += dif;
              s1[l] = '0' + i;
              c1--;
            }
        if (first != 0)
          for (long long l = s1.size() - 1; l >= 0 && c1 > 0; l--)
            if (s1[l] == '0' + i - dif) {
              temp += dif;
              s1[l] = '0' + i;
              c1--;
            }
        dif++;
      }
      if (ans > temp) {
        ans = temp;
        a = s1;
      } else if (ans == temp) {
        a = min(a, s1);
      }
    }
  cout << ans << '\n' << a;
  return 0;
}
