#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
  point(double x, double y) : x(x), y(y) {}
  point() { x = y = 0.0; }
  point operator+(point q) { return point(x + q.x, y + q.y); }
  point operator-(point q) { return point(x - q.x, y - q.y); }
  point operator*(double t) { return point(x * t, y * t); }
  point operator/(double t) { return point(x / t, y / t); }
  double operator*(point q) { return q.x * x + q.y * y; }
  double operator%(point q) { return x * q.y - y * q.x; }
};
const double PI = 2.0 * acos(0.0);
inline int getInt() {
  int x;
  scanf("%d", &x);
  return x;
}
inline long long getLL() {
  long long x;
  scanf("%lld", &x);
  return x;
};
inline int NUM(char c) { return (int)c - 48; }
inline char CHR(int n) { return (char)(n + 48); }
template <class T>
inline T MAX(T a, T b) {
  if (a > b) return a;
  return b;
}
template <class T>
inline T MIN(T a, T b) {
  if (a < b) return a;
  return b;
}
inline int BPM(int a, int b, int MOD) {
  if (a == 0) return 0;
  if (b == 0) return 1 % MOD;
  if (b % 2 == 1) return (int)((long long)BPM(a, b - 1, MOD) * a % MOD);
  int tmp = BPM(a, b / 2, MOD);
  return (int)((long long)tmp * tmp % MOD);
}
inline int phi(int N) {
  int ret = N;
  for (int i = 2; N > 1; i++) {
    if (i * i > N) {
      ret -= ret / N;
      break;
    }
    if (N % i == 0) {
      ret -= ret / i;
      while (N % i == 0) N /= i;
    }
  }
  return ret;
}
inline void OPEN(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
char s[10000 + 5];
vector<string> sols;
string x;
int N, K;
vector<int> v;
int main() {
  scanf("%d%d", &N, &K);
  scanf("%s", s);
  for (int i = 0, _n = (N); i < _n; i++) s[i] = NUM(s[i]);
  int mn = 1000000005;
  for (int d = (0), _b = (9); d <= _b; d++) {
    int ctr = K;
    for (int i = 0, _n = (N); i < _n; i++) {
      if (s[i] == d) {
        ctr--;
      }
    }
    v.clear();
    for (int i = 0, _n = (N); i < _n; i++) {
      if (s[i] != d) {
        v.push_back(abs(s[i] - d));
      }
    }
    sort((v).begin(), (v).end());
    int tmp = 0;
    for (int i = 0, _n = (ctr); i < _n; i++) {
      tmp += v[i];
    }
    if (tmp < mn) {
      mn = tmp;
      sols.clear();
    }
    x.resize(N);
    int xx = ctr;
    ctr--;
    if (tmp <= mn) {
      if (ctr >= 0) {
        for (int i = 0, _n = (N); i < _n; i++) {
          if (s[i] != d && abs(s[i] - d) < v[ctr]) {
            x[i] = CHR(d);
            xx--;
          } else {
            x[i] = CHR(s[i]);
          }
        }
        for (int i = 0, _n = (N); i < _n; i++) {
          if (xx > 0 && abs(s[i] - d) == v[ctr] && s[i] > d) {
            x[i] = CHR(d);
            xx--;
          }
        }
        for (int i = (N)-1; i >= 0; i--) {
          if (xx > 0 && abs(s[i] - d) == v[ctr] && s[i] < d) {
            x[i] = CHR(d);
            xx--;
          }
        }
      } else {
        for (int i = 0, _n = (N); i < _n; i++) {
          x[i] = CHR(s[i]);
        }
      }
      sols.push_back(x);
    }
  }
  sort((sols).begin(), (sols).end());
  printf("%d\n%s\n", mn, sols[0].c_str());
  return 0;
}
