#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int n, K;
string A, B;
pair<int, string> ans[10];
int main() {
  read_file();
  while (scanf("%d%d", &n, &K) != EOF) {
    cin >> A;
    for (int j = 0; j <= 9; j++) {
      int rem = 0;
      for (int i = 0; i < n; i++) rem += A[i] - '0' == j;
      rem = K - rem;
      B = A;
      int cost = 0;
      for (int dd = 1; dd <= 9 && rem > 0; dd++) {
        for (int sgn = +1; sgn >= -1 && rem > 0; sgn -= 2) {
          int d = j + sgn * dd;
          if (0 <= d && d <= 9)
            ;
          else
            continue;
          if (sgn == 1) {
            for (int i = 0; i < n && rem > 0; i++) {
              if (B[i] - '0' != d) continue;
              B[i] = j + '0';
              cost += abs(d - j);
              rem--;
            }
          } else {
            for (int i = n - 1; i >= 0 && rem > 0; i--) {
              if (B[i] - '0' != d) continue;
              B[i] = j + '0';
              cost += abs(d - j);
              rem--;
            }
          }
        }
      }
      ans[j] = make_pair(cost, B);
    }
    pair<int, string> sth = *min_element(ans, ans + 10);
    printf("%d\n%s\n", sth.first, sth.second.c_str());
  }
}
