#include <bits/stdc++.h>
using namespace std;
void fastIO() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
template <typename T, typename U>
inline void mnze(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void mxze(T &x, U y) {
  if (x < y) x = y;
}
void _scan(int &x) { scanf("%d", &x); }
void _scan(long long &x) { scanf("%lld", &x); }
void _scan(double &x) { scanf("%lf", &x); }
void _scan(char &x) { scanf(" %c", &x); }
void _scan(char *x) { scanf("%s", x); }
void scan() {}
template <typename T, typename... U>
void scan(T &head, U &...tail) {
  _scan(head);
  scan(tail...);
}
template <typename T>
void _dbg(const char *sdbg, T h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename T, typename... U>
void _dbg(const char *sdbg, T h, U... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
long long MOD = 1e9 + 7;
inline long long Msum(long long x) { return x; }
template <typename... Rest>
inline long long Msum(long long x, Rest... rest) {
  return (x + Msum(rest...)) % MOD;
}
inline long long Mprod(long long x) { return x; }
template <typename... Rest>
inline long long Mprod(long long x, Rest... rest) {
  return x * Mprod(rest...) % MOD;
}
inline long long Mnorm(long long x) { return (x % MOD + MOD) % MOD; }
const int MAXN = 2e5 + 5;
int n, k, a[MAXN];
char A[MAXN];
int cil;
vector<int> dp[MAXN][2], god[MAXN][2];
vector<pair<int, int> > go[MAXN][2];
bool f(int i, int b, int j) {
  if (i == k) return b;
  int &ret = dp[i][b][j];
  if (ret != -1) return ret;
  for (int d = 0; d < 10; d++) {
    int nj = cil;
    int e;
    for (int jj = 0; i + jj * k < n && nj == cil; jj++) {
      if (d != a[i + jj * k] && jj < nj) {
        e = a[i + jj * k];
        nj = jj;
      }
    }
    int nb;
    if (nj < j)
      nb = d > e;
    else
      nj = j, nb = b;
    bool nret = f(i + 1, nb, nj);
    if (nret) {
      god[i][b][j] = d;
      go[i][b][j] = {nb, nj};
      return (ret = true);
    }
  }
  return (ret = false);
}
char ans[MAXN];
int main() {
  scan(n, k);
  scan(A);
  for (int i = 0; i < n; i++) a[i] = A[i] - '0';
  cil = (n + k - 1) / k;
  for (int i = 0; i <= k; i++) {
    dp[i][0].resize(cil + 1, -1);
    god[i][0].resize(cil + 1, -1);
    go[i][0].resize(cil + 1);
    dp[i][1].resize(cil + 1, -1);
    god[i][1].resize(cil + 1, -1);
    go[i][1].resize(cil + 1);
  }
  assert(f(0, 1, cil));
  int b = 1, j = cil;
  for (int i = 0; i < k; i++) {
    int d = god[i][b][j];
    for (int jj = 0; i + jj * k < n; jj++) {
      ans[i + jj * k] = d + '0';
    }
    pair<int, int> t = go[i][b][j];
    b = t.first;
    j = t.second;
  }
  printf("%d\n%s\n", n, ans);
}
