#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
pair<int, string> ans[10];
int main() {
  cin >> n >> k >> s;
  for (int i = 0; i < 10; i++) {
    int cnt = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] - '0' == i) {
        cnt++;
      }
    }
    ans[i].second = s;
    for (int d = 1; d < 10; d++) {
      for (int j = 0; j < s.size(); j++) {
        if ((s[j] - '0') - i == d && cnt < k) {
          ans[i].second[j] = i + '0';
          ans[i].first += d;
          cnt++;
        }
      }
      for (int j = s.size() - 1; j >= 0; j--) {
        if (i - (s[j] - '0') == d && cnt < k) {
          ans[i].second[j] = i + '0';
          ans[i].first += d;
          cnt++;
        }
      }
    }
  }
  sort(ans, ans + 10);
  cout << ans[0].first << endl << ans[0].second << endl;
  return 0;
}
