#include <bits/stdc++.h>
using namespace std;
int a, b, c, n, m, k = 0, T, x[100010], dp[100010], head[100010],
                   maxx = -0x3f3f3f3f;
struct node {
  int u, v, Next;
} t[2 * 100010];
void add(int u, int v) {
  t[++k].v = v;
  t[k].Next = head[u];
  head[u] = k;
}
int main() {
  int minn = 0x3f3f3f3f;
  string A, B, C;
  scanf("%d%d", &n, &m);
  cin >> A;
  for (int i = 0; i <= 9; i++) {
    int sum = 0, cnt = 0;
    ;
    B = A;
    for (int k = 0; k <= 9; k++) {
      if (i + k <= 9)
        for (int j = 0; j < A.size(); j++) {
          if (cnt == m) break;
          if (A[j] - '0' == i + k) cnt++, sum += k, B[j] = i + '0';
        }
      if (i - k >= 0 && k != 0)
        for (int j = A.size() - 1; j >= 0; j--) {
          if (cnt == m) break;
          if (A[j] - '0' == i - k) cnt++, sum += k, B[j] = i + '0';
        }
    }
    if (sum < minn) {
      minn = sum;
      C = B;
    } else if (sum == minn && B < C) {
      C = B;
    }
  }
  cout << minn << endl << C;
}
