#include <bits/stdc++.h>
using namespace std;
char arr[10005];
int N;
pair<int, string> tryN(int num, int K) {
  string ret = arr;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      PQ;
  for (int i = 0; i < N; ++i)
    PQ.push(pair<int, int>(abs(num - (arr[i] - '0')),
                           (arr[i] - '0' >= num ? -1 : 1) * (N - i)));
  int cost = 0;
  for (int i = 0; i < K; ++i) {
    pair<int, int> c = PQ.top();
    PQ.pop();
    ret[N - abs(c.second)] = num + '0';
    cost += c.first;
  }
  return pair<int, string>(cost, ret);
}
int main() {
  int K;
  cin >> N >> K >> arr;
  pair<int, string> arr[10];
  for (int i = 0; i <= 9; ++i) {
    arr[i] = tryN(i, K);
  }
  sort(arr, arr + 10);
  cout << arr[0].first << endl;
  cout << arr[0].second << endl;
}
