#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> arr;
int main() {
  int n, k;
  string str;
  cin >> n >> k >> str;
  string res = str;
  long long int tot = 50000000000009999ll;
  for (int i = 0; i <= 9; i++) {
    arr.clear();
    for (int j = 0; j < str.size(); j++) {
      if (str[j] >= i + '0')
        arr.push_back({abs(str[j] - '0' - i), -(n - j)});
      else
        arr.push_back({abs(str[j] - '0' - i), (n - j)});
    }
    sort(arr.begin(), arr.end());
    long long int cnt = 0;
    string second = str;
    for (int j = 0; j < k; j++) {
      cnt += arr[j].first;
      int idx = n - abs(arr[j].second);
      second[idx] = '0' + i;
    }
    if (cnt < tot) {
      tot = cnt;
      res = second;
    } else if (cnt == tot && res > second)
      res = second;
  }
  cout << tot << "\n" << res;
  return 0;
}
