#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
long long mpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a;
    a = a * a;
    n >>= 1;
  }
  return res;
}
signed main() {
  ll n, k;
  cin >> n >> k;
  string s, t, ans;
  cin >> s;
  t = s;
  reverse((t).begin(), (t).end());
  s += t;
  vector<string> sub(0);
  for (int i = 0; i <= (ll)(s).size() - n; i++) {
    sub.push_back(s.substr(i, n));
  }
  sort((sub).begin(), (sub).end());
  t = sub[0];
  int ind = 0;
  for (ll i = 0; i < (ll)((ll)(t).size() + 1); i++) {
    if (i == (ll)(t).size()) {
      ind = (ll)(t).size();
      break;
    }
    if (t[i] != t[0]) {
      ind = i;
      break;
    }
  }
  cout << ind << endl;
  if (k >= 13 || ind * mpow(2, k - 1) >= n) {
    ans = string(n, t[0]);
  } else {
    ans = string(ind * mpow(2, k - 1), t[0]);
    ans += t.substr(ind, n - ind * mpow(2, k - 1));
  }
  cout << ans << endl;
}
