#include <bits/stdc++.h>
int A[20], B[20];
void parr(int arr[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    printf("%d", arr[i]);
  }
}
int *smaller(int arr[], int brr[], int n) {
  int i, p, q;
  for (i = 0; i < n; i++) {
    if (arr[i] > brr[i]) {
      return brr;
    } else if (brr[i] > arr[i]) {
      return arr;
    }
  }
  return arr;
}
int coast(int x, int k, int a[], int *fuck) {
  int i, j, ans = 0, f = 0, p, q, flag = 0;
  for (i = 0; i < 10; i++) {
    if (i == 0) {
      f += a[x];
      if (f >= k) {
        *fuck = i;
        return 0;
      }
    } else {
      if (x + i < 10 && f + a[x + i] < k) {
        f += a[x + i];
        ans += i * a[x + i];
      } else if (x + i < 10) {
        p = k - f;
        ans += p * i;
        *fuck = i;
        return ans;
      }
      if (x - i >= 0 && f + a[x - i] < k) {
        f += a[x - i];
        ans += i * a[x - i];
      } else if (x - i >= 0) {
        p = k - f;
        ans += p * i;
        *fuck = i;
        return ans;
      }
    }
  }
}
int shr(int y, int sh, int a[]) {
  int i, ans;
  ans = a[sh];
  for (i = 1; i < y; i++) {
    ans += a[sh + i];
    ans += a[sh - i];
  }
  return ans;
}
int main() {
  int i, j, k, n, f, m, p, a[20], x, c[20], baal[10005], min, sh, y,
      cnt = 0, X = 0, Y = 0, flag, arr[10][10005], susu[10005];
  int *fu;
  for (i = 0; i < 20; i++) {
    a[i] = 0;
  }
  scanf("%d", &n);
  ;
  scanf("%d", &p);
  ;
  for (i = 0; i < n; i++) {
    susu[i] = 9;
  }
  fu = susu;
  for (i = 0; i < n; i++) {
    scanf("%1d", &x);
    a[x]++;
    baal[i] = x;
    for (j = 0; j < 10; j++) {
      arr[j][i] = x;
    }
  }
  for (i = 0; i < 10; i++) {
    c[i] = coast(i, p, a, &y);
  }
  min = c[0];
  sh = 0;
  for (i = 0; i < 10; i++) {
    if (min > c[i]) {
      min = c[i];
      sh = i;
    }
  }
  for (j = 0; j < 10; j++) {
    if (min == c[j]) {
      sh = j;
      coast(j, p, a, &y);
      k = shr(y, sh, a);
      k = p - k;
      for (i = 0; i < n; i++) {
        if (abs(arr[j][i] - sh) < y) {
          arr[j][i] = sh;
        }
      }
      for (i = 0; i < n; i++) {
        if (arr[j][i] - sh == y && k) {
          arr[j][i] = sh;
          k--;
        }
      }
      for (i = n - 1; i >= 0; i--) {
        if (sh - arr[j][i] == y && k) {
          arr[j][i] = sh;
          k--;
        }
      }
    }
  }
  for (i = 0; i < 10; i++) {
    if (c[i] == min) fu = smaller(fu, arr[i], n);
  }
  printf("%d\n", min);
  parr(fu, n);
  return 0;
}
